feat(studio): refine Play workspace and project preferences (WRK-001D)
This commit is contained in:
@@ -23,14 +23,28 @@ Run these commands from the Studio repository root:
|
||||
standalone foundation shell is an explicit developer command,
|
||||
`./gradlew :prometeu-studio-ui-javafx-2:run`; it does not open after Studio exits.
|
||||
|
||||
The project chooser contains project commands and inherits your presentation
|
||||
preferences. Language, theme, typeface and scale controls belong to the project
|
||||
window. Closing the chooser exits Studio without opening a shell.
|
||||
The project chooser contains project commands and a Prometeu Studio menu. Open
|
||||
**Prometeu Studio > Preferences** for language, theme, typeface, text scale and the default
|
||||
runtime installation. Closing the chooser exits Studio without opening a shell.
|
||||
|
||||
Open an existing project from the project chooser and select a qualified runtime
|
||||
installation. Use Play, Pause, Resume and Stop to run the game inside Studio.
|
||||
Games with saves require an existing development save image or an explicitly
|
||||
disposable session. Close the project before opening another.
|
||||
Open an existing project and use the global **Play/Stop** button and separate
|
||||
**Pause/Resume** toggle. **Project > Settings** contains an optional
|
||||
runtime override and memory card settings. Projects inherit the Studio runtime
|
||||
when the override is empty. Games with saves require an existing development save
|
||||
image or an explicitly disposable session; disposable mode resets when the project
|
||||
closes. Use **Project > Close project** before opening another project.
|
||||
|
||||
The top controls stay on the right, leaving room for menus; project information
|
||||
appears in the compact header.
|
||||
The workspace has balanced space above and below the tabs, with the active tab's
|
||||
gold outline enclosing its content.
|
||||
The **Gameplay** tab fits the image to its available surface. The footer follows
|
||||
the selected tab and shows Gameplay's effective scale. Enable **Manual scale** for
|
||||
a 25–400% slider; oversized manual images scroll.
|
||||
Drag the divider between game and logs to give either region more room. Automatic
|
||||
scale follows the available game area; manual scale keeps your chosen size.
|
||||
Window position, normal size and maximization are remembered for the project
|
||||
chooser and separately for each project.
|
||||
|
||||
The default frontend is `prometeu-studio-ui-javafx-2`. It provides project opening
|
||||
and integrated Play; editors, Assets/DEV/Shipper workspaces and MCP grant controls
|
||||
|
||||
+42
-2
@@ -177,11 +177,38 @@ shield follows actual opening steps and remains visible for at least one second,
|
||||
counted in parallel with preparation. Opening a project does not compile or start
|
||||
the game. Closing its window stops execution and returns to the launcher.
|
||||
|
||||
The launcher inherits presentation preferences and has no language, theme,
|
||||
typeface or scale controls. Closing it exits Studio. `./gradlew run` at the root
|
||||
The launcher inherits presentation preferences and offers **Prometeu Studio > Preferences**
|
||||
instead of permanent appearance selectors. This dialog also sets the machine-local
|
||||
runtime default; **Project > Settings** configures an optional override and save
|
||||
media. Interactive Play freezes the effective runtime for both asset capacity
|
||||
qualification and launch, leaving inherited project configuration null. Headless
|
||||
and MCP configuration remains project-specific.
|
||||
|
||||
The global Play/Stop button and Pause/Resume toggle stay on the right above the
|
||||
Gameplay tab, moving together onto a second right-aligned row when navigation
|
||||
needs the space. State text
|
||||
lives in the project header. The equal-height footer follows the selected tab and
|
||||
shows Gameplay's effective scale. Native tabs use stepped upper corners and a flat,
|
||||
open base joining the content, without a button's lower bevel. Studio identity
|
||||
appears once in the launcher's menu. Gameplay automatically fits the native frame
|
||||
to its surface; the optional manual slider
|
||||
uses 25–400% scale, with scrolling for oversized images. Window geometry is stored
|
||||
in `~/.prometeu-studio/window-state.json`; the runtime default is stored separately
|
||||
in `~/.prometeu-studio/runtime-settings.json`. Neither is portable game metadata.
|
||||
Closing the launcher exits Studio. `./gradlew run` at the root
|
||||
launches only the product; the independent shell/gallery require their explicit
|
||||
module commands and do not run after the product closes.
|
||||
|
||||
The active tab's gold outline encloses its content with an opening below the tab
|
||||
header. The product workspace uses a plain surface and equal top/bottom margins;
|
||||
there is no additional decorative frame around the tabs. The standalone foundation
|
||||
shell retains its panel. Gameplay contains a vertical SplitPane: game/local scale controls above,
|
||||
logs below, initially around 80/20. Drag its horizontal divider to prioritize logs
|
||||
or game. Automatic fitting follows the resulting render area, including while
|
||||
paused; manual mode preserves the chosen scale and uses scrolling. The split stays
|
||||
with the open view and is not stored as a project preference. Header/footer stay
|
||||
outside the split. The outline decoration does not participate in layout or hit testing.
|
||||
|
||||
Qualify these windows without a native runtime using disposable projects and
|
||||
isolated presentation storage:
|
||||
|
||||
@@ -194,6 +221,19 @@ Scene captures and environment metadata are written to
|
||||
wizard, appearance, geometry, failure feedback and late-session cleanup; the
|
||||
separate Play gates below exercise the native process and game lifecycle.
|
||||
|
||||
Check command position and painting with real Robot mouse events, screen captures
|
||||
and a repaint reference across themes, locales and text scales:
|
||||
|
||||
```bash
|
||||
./gradlew :prometeu-app:studioControlsDesktopTest
|
||||
```
|
||||
|
||||
Captures and pixel comparisons are written to
|
||||
`prometeu-app/build/controls-desktop-captures`. The diagnostic fixture retains the
|
||||
old wrapping layout to measure displacement; the stable-layout gate exercises the
|
||||
current execution bar. These checks do not replace human confirmation of a reported
|
||||
artifact that cannot be reproduced on the qualification machine.
|
||||
|
||||
Requires a desktop environment and an installed native runtime:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -16,8 +16,9 @@ own explicit contracts.
|
||||
## Shell
|
||||
|
||||
The standalone foundation launch MUST show a native-decorated window with Studio
|
||||
identity, presentation selectors and an empty working area. The product mounts its
|
||||
chooser/Play view there. Minimum outer size is 680×480; the foundation initial scene
|
||||
identity, presentation selectors and an empty working area. The product uses its
|
||||
own menu/toolbar shell and Gameplay tab as specified in specification 14; the
|
||||
standalone selectors are developer demonstrations. Minimum outer size is 680×480; the foundation initial scene
|
||||
is 1200×800, and the integrated product starts at 1200×850. Toolbar content MUST
|
||||
wrap/reflow instead of requiring horizontal scrolling at the minimum width.
|
||||
|
||||
|
||||
@@ -15,10 +15,75 @@ Opening MUST hide the launcher and present a separate loading shield; the projec
|
||||
window MUST appear only after preparation and the minimum shield duration.
|
||||
A project MUST be closed before another can open. Closing returns to the
|
||||
launcher after execution and session cleanup. Startup MUST NOT automatically
|
||||
restore the previous project. Project-window geometry MUST be restored per
|
||||
project through the neutral window-state port.
|
||||
restore the previous project. Launcher geometry and project-window geometry MUST
|
||||
be stored independently through the neutral window-state port. Project keys are
|
||||
normalized absolute project paths. Geometry MUST preserve normal position/size
|
||||
separately from maximization, survive orderly application restart and leave the
|
||||
title bar reachable when monitors change. Available secondary displays, including
|
||||
negative coordinates, MUST be considered instead of clamping every window to the
|
||||
primary display. Writes MUST be serialized, atomic and off the FX thread; orderly
|
||||
close MUST flush pending snapshots. Transient native show/maximization events MUST
|
||||
NOT overwrite the saved normal geometry. Legacy geometry remains readable.
|
||||
|
||||
This slice exposes a global Play/Stop button, a separate Pause/Resume toggle, a
|
||||
Gameplay tab with the game viewport, and bounded logs. Execution belongs to the
|
||||
project session, independently of tab selection or lifetime. The global toolbar
|
||||
MUST remain above the tabs. Starting Play selects Gameplay. Pause selection,
|
||||
accessible names and command availability MUST follow observed execution state,
|
||||
including automatic pauses and failures. Stop MUST remain Stop until execution
|
||||
ownership is actually relinquished, including when paused. Transitioning commands
|
||||
MUST NOT be submitted repeatedly.
|
||||
|
||||
The top row MUST place the golden-square Studio mark and **Prometeu Studio** menu
|
||||
on the left, followed by project navigation. The Play/Stop and Pause/Resume pair
|
||||
MUST be anchored at the right padding, leaving the intervening space available
|
||||
for navigation independently of status text. When navigation and the pair would
|
||||
overlap, the pair MUST occupy a second row, also aligned right. Each command MUST
|
||||
reserve enough width for all its
|
||||
translated labels at the active typeface and text scale. State changes MUST NOT
|
||||
move the pair or resize its slots. The pause toggle MUST visibly read **Resume**
|
||||
when paused and **Pause** otherwise, consistently with its accessible name and
|
||||
tooltip. Keyboard focus MUST remain visible within the control's drawing envelope.
|
||||
|
||||
A compact project-information header MUST sit below the top area. It contains
|
||||
project identity and execution status, including transient/disposable status,
|
||||
separate from command layout. A footer MUST remain at the bottom of the window,
|
||||
with the same height as the header at the current text scale. It MUST display
|
||||
information supplied by the selected tab; unregistered tabs MUST show no inherited
|
||||
status. Gameplay supplies the effective scale or a waiting-for-image status.
|
||||
Overflowing information MUST ellipsize without displacing commands. At small window
|
||||
sizes or large text scales, content MUST remain scrollable while both information
|
||||
strips remain outside the scrolling content.
|
||||
|
||||
The product workspace between header and footer MUST use a plain surface without
|
||||
an additional decorative frame around the tabs. Its top and bottom margins MUST
|
||||
be equal, initially 18 logical pixels, while retaining the horizontal inset and
|
||||
filling the remaining space. This MUST preserve scrolling for constrained windows
|
||||
and MUST NOT remove the active tab's gold outline around its own content. The
|
||||
standalone foundation shell/gallery retains its decorative panel.
|
||||
|
||||
Tabs MUST retain native selection, focus and keyboard behavior and the inherited
|
||||
Studio typeface. Tabs MUST use stepped upper corners and a flat base without the
|
||||
lower bevel or bottom outline of a button. The selected tab MUST join the content
|
||||
surface, with a gold accent on its top and sides. Semantic theme colors MUST retain
|
||||
distinct selected, hovered, disabled and focused states. This slice MUST NOT add
|
||||
placeholder editors or extra tabs.
|
||||
|
||||
The gold outline MUST continue from the active tab header around its entire content
|
||||
area, joining the header's sides without drawing a line across the opening below
|
||||
it. The outline MUST follow selection and layout, disappear for empty content and
|
||||
remain outside hit testing and layout measurement. It MUST NOT obscure keyboard
|
||||
focus or leave the previous tab's outline after selection/removal.
|
||||
|
||||
Gameplay MUST contain both the game surface/local scale controls and bounded logs,
|
||||
with an adjustable horizontal divider between game above and logs below. The
|
||||
initial division SHOULD prioritize the game at approximately 80/20. Both regions
|
||||
MUST retain usable minimum sizes and scrolling when needed. The divider MUST follow
|
||||
the Studio theme and indicate drag affordance. Header/footer and global execution
|
||||
controls MUST remain outside that split. Adjusting it MUST NOT change execution
|
||||
state or restart the runtime. The split is retained for the open view; it does not
|
||||
introduce persisted project settings or a restoration contract across reopening.
|
||||
|
||||
This slice exposes Play, Pause, Resume, Stop, a game viewport, and bounded logs.
|
||||
It MUST NOT initialize an AI client or editor/LSP infrastructure when opening for
|
||||
Play. Existing headless, MCP, evidence, tests and agent contracts remain available
|
||||
through their existing entry points and services. Their preservation takes
|
||||
@@ -37,13 +102,19 @@ a selection; Open MUST also work by double click or Enter. Adding a manifest MUS
|
||||
validate, remember and select it without automatically opening. Forget MUST remove
|
||||
only the catalogue reference, never files. Cancelled file selection MUST leave the
|
||||
catalogue unchanged. Empty and failed states MUST provide visible feedback.
|
||||
The launcher MUST contain project selection/management and identity only, without
|
||||
global language, theme, typeface or scale controls. It MUST inherit the existing
|
||||
presentation settings; those controls belong to the project window. Closing the
|
||||
The launcher MUST contain project selection/management, identity and access to
|
||||
Studio preferences, without permanently exposed language, theme, typeface or scale
|
||||
selectors. It MUST inherit the existing presentation settings. Closing the
|
||||
launcher MUST exit Studio without presenting an empty project/foundation shell.
|
||||
Studio identity MUST appear in the Prometeu Studio menu with its icon; the project
|
||||
chooser MUST NOT repeat that identity in a separate block below the menu. The
|
||||
project-section title, catalogue and commands MUST remain visible.
|
||||
The internal project frame MUST grow and shrink with the available launcher width
|
||||
and height, allocating additional height to the project list. Smaller viewports or
|
||||
larger text scales MUST retain scrolling so project commands remain accessible.
|
||||
The chooser MUST use equal 18px outer margins and one 18px panel inset, with 18px
|
||||
between title/list/actions and 12px between actions. Empty feedback MUST NOT reserve
|
||||
space; visible feedback MUST align with the outer margins without doubled gaps.
|
||||
|
||||
The creation wizard MUST use UI2 components and preserve five steps: name,
|
||||
language/stdlib/source root, indentation/runtime details, parent location and
|
||||
@@ -64,7 +135,11 @@ provide the loading mechanism. Unmeasurable work MUST use indeterminate progress
|
||||
time-driven percentages MUST NOT stand in for actual progress.
|
||||
|
||||
The shield MUST identify Studio, its version, the project and current phase. It
|
||||
MUST remain visible for at least one second, measured with a monotonic clock from
|
||||
MUST use equal 18px outer margins, one 18px panel inset and 18px between content
|
||||
groups. Content MUST be centered vertically when space permits, with scrolling for
|
||||
constrained space or larger text. These refinements MUST preserve window sizing,
|
||||
positioning and opening behavior. It MUST remain visible for at least one second,
|
||||
measured with a monotonic clock from
|
||||
presentation, in parallel with preparation. The project is ready when validation,
|
||||
session acquisition, required persistence and view composition succeed. If ready
|
||||
before the minimum, show completion while awaiting the remainder; if slower,
|
||||
@@ -88,6 +163,32 @@ request application exit when closed; closing the project window MUST request
|
||||
project closure and return to selection under the existing Stop/save rules.
|
||||
Timers, views and appearance subscriptions MUST be disposed with their owners.
|
||||
|
||||
## Preferences and project configuration
|
||||
|
||||
Prometeu Studio > Preferences MUST open a separate dialog for theme, language, typeface,
|
||||
UI text scale and the machine-local default runtime installation. Project >
|
||||
Settings MUST open a separate dialog for the optional runtime override and save
|
||||
media configuration. Project > Close project retains coordinated teardown.
|
||||
Runtime and save fields MUST NOT be mounted permanently in Gameplay. Apply MUST
|
||||
validate and publish settings off the FX thread; Cancel MUST leave stored choices
|
||||
unchanged. Appearance forms use draft state until Apply. Execution configuration
|
||||
MUST remain unavailable while execution ownership is held; appearance preferences
|
||||
remain usable. Missing configuration MUST provide an action to open its settings.
|
||||
|
||||
Interactive Play MUST resolve the project override when present, otherwise the
|
||||
Studio default. Inheritance MUST remain null in the persisted project setup; the
|
||||
effective installation MUST be frozen in memory for both build capacity admission
|
||||
and runtime launch. New global selections affect subsequent starts. An invalid
|
||||
explicit override MUST fail visibly rather than silently select another runtime.
|
||||
Existing project overrides MUST remain intact. The global installation is stored
|
||||
locally, separately from frontend appearance. This rule MUST NOT change the
|
||||
existing project-specific headless/MCP configuration contracts.
|
||||
|
||||
Save media paths remain machine-local project settings. Disposable save MUST be
|
||||
an explicit temporary choice for the open project, reset on reopening, and MUST
|
||||
be identified in execution status. Missing save media MUST NOT implicitly select
|
||||
disposable mode. Existing write exclusion and save protection remain mandatory.
|
||||
|
||||
## Preparation, process and authority
|
||||
|
||||
Play MUST reuse the compiler/Packer/Shipper preparation pipeline to produce the
|
||||
@@ -169,12 +270,24 @@ FX polls the latest complete frame on a pulse, copies it to an FX-owned
|
||||
`WritableImage`, and releases the lease. Reception MUST NOT enqueue one FX task
|
||||
per frame. Logs and frontend projections MUST remain bounded.
|
||||
|
||||
Zoom choices MUST be x1, x2 and x4 with nearest-neighbor presentation. At x1 a
|
||||
640×360 game occupies 640×360 logical pixels, respecting OS scale; it does not mean
|
||||
one physical display pixel. Oversized images MUST retain zoom and scroll. The UI
|
||||
MUST NOT silently fit the image or change zoom.
|
||||
Gameplay MUST default to uniform automatic scaling to the largest image that
|
||||
fits the available surface. Window or Gameplay divider resize MUST recompute the scale, preserve aspect ratio
|
||||
and center the image with margins when needed, without scrollbars in automatic
|
||||
mode. The Gameplay footer's percentage and multiplier MUST describe the effective scale
|
||||
relative to native frame dimensions. UI text scale is independent of game scale.
|
||||
|
||||
Input MUST invert the image's scene transform and selected logical zoom. Touch
|
||||
A Manual scale checkbox MUST enable a continuous slider from 25% to 400% of
|
||||
native dimensions, initially using the current fitted scale clamped to that range.
|
||||
Manual images larger than the surface MUST remain accessible by scrolling.
|
||||
Disabling manual mode returns to automatic fit; reopening a project resets manual
|
||||
mode. Presentation retains nearest-neighbor sampling, including fractional scale.
|
||||
Divider movement MUST preserve the chosen manual scale and update the visible
|
||||
scroll area. Automatic fitting MUST also respond while paused, without requiring
|
||||
a new runtime frame; disabling manual mode fits the current render area.
|
||||
This replaces the former discrete x1/x2/x4 and mandatory 1:1 presentation contract.
|
||||
|
||||
Input MUST invert the image's actual scene transform and displayed dimensions,
|
||||
including fractional scale, centering margins and manual scroll. Touch
|
||||
outside the image MUST release/reject touch rather than clamp to an edge. Keyboard
|
||||
input belongs to the focused viewport, with modifiers reserved for application
|
||||
shortcuts. Pad keys are arrows, A/D/W/S for A/B/X/Y, Q/E for L/R, Z for Start and
|
||||
@@ -185,7 +298,7 @@ The only native machine output is 640×360 RGBA8888 at 60 Hz. The new JavaFX 2
|
||||
viewport obtains dimensions from complete runtime publications; it MUST NOT keep
|
||||
an independent fallback resolution. Leaving the image cancels an active contact;
|
||||
dragging back while still held MUST NOT recapture without a new press inside.
|
||||
Zoom and scroll continue to operate in JavaFX logical coordinates, with scene
|
||||
Scale and scroll operate in JavaFX logical coordinates, with scene
|
||||
transforms accounting for host display scaling. These frontend changes apply to
|
||||
the new UI only; the old UI is outside the current graphics migration scope.
|
||||
|
||||
|
||||
@@ -257,3 +257,16 @@ tasks.register<Test>("assetCapacityProcessTest") {
|
||||
include("**/AssetManagedBuildInstalledRuntimeTest.class")
|
||||
systemProperty("studio.test.runtimeInstall", providers.gradleProperty("studioRuntimeInstall").getOrElse(""))
|
||||
}
|
||||
|
||||
tasks.register<Test>("studioControlsDesktopTest") {
|
||||
group = "verification"
|
||||
description = "Checks native mouse rendering and the Studio shell in isolated JavaFX windows."
|
||||
testClassesDirs = sourceSets["test"].output.classesDirs
|
||||
classpath = sourceSets["test"].runtimeClasspath
|
||||
useJUnitPlatform()
|
||||
include("**/StudioControlsDesktopTest.class")
|
||||
systemProperty("java.awt.headless", "false")
|
||||
systemProperty("studio.test.controlsCaptures", layout.buildDirectory.dir("controls-desktop-captures").get().asFile.absolutePath)
|
||||
outputs.upToDateWhen { false }
|
||||
testLogging.showStandardStreams = true
|
||||
}
|
||||
|
||||
@@ -179,6 +179,12 @@ public class StudioApplicationConfiguration {
|
||||
return new JsonWindowStateStore(resolveWindowStateStorage(), mapper);
|
||||
}
|
||||
|
||||
@Bean
|
||||
p.studio.api.preferences.RuntimeSettingsStore runtimeSettingsStore(ObjectMapper mapper) {
|
||||
return new p.studio.core.project.preferences.JsonRuntimeSettingsStore(
|
||||
Path.of(System.getProperty("user.home"), ".prometeu-studio", "runtime-settings.json"), mapper);
|
||||
}
|
||||
|
||||
@Bean
|
||||
ProjectActivityHistoryStore projectActivityHistoryStore(ObjectMapper mapper) {
|
||||
return new JsonProjectActivityHistoryStore(mapper);
|
||||
@@ -325,7 +331,8 @@ public class StudioApplicationConfiguration {
|
||||
WindowStateStore windowStateStore,
|
||||
ProjectActivityHistoryStore activityHistoryStore, p.studio.api.automation.AgentConnectionGuide connectionGuide,
|
||||
p.studio.api.assets.animation.AnimationService animationService,ObjectMapper mapper,OperationExecutor operations,
|
||||
p.studio.core.project.ProjectAccessRegistry access,ProjectLocalStudioSetupStore setupStore) {
|
||||
p.studio.core.project.ProjectAccessRegistry access,ProjectLocalStudioSetupStore setupStore,
|
||||
p.studio.api.preferences.RuntimeSettingsStore runtimeSettings) {
|
||||
var factory = new StudioUiFactory(projectCatalog, knownProjects, languageCatalog, projectSessionFactory,
|
||||
executionControllerFactory, projectWorkspaceInitializer, studioExecutor, i18n, theme, eventBus, shipper,
|
||||
assetCatalog, assetCommands, assetPacking, assetDetails, assetCreationCatalog, assetMetadataService,
|
||||
@@ -333,6 +340,7 @@ public class StudioApplicationConfiguration {
|
||||
tiledAssetService, sceneBankWorkflow, windowStateStore,
|
||||
activityHistoryStore, connectionGuide);
|
||||
factory.setAnimationService(animationService);
|
||||
factory.setRuntimeSettings(runtimeSettings);
|
||||
factory.enableInteractive(new p.studio.core.execution.DefaultExecutionControllerFactory(shipper,
|
||||
new p.studio.app.runtime.studio.StudioRuntimeGateway(mapper),operations,access),
|
||||
(project,setup)->{try(var lease=access.enterManual(project.rootPath())){setupStore.save(project,setup);}});
|
||||
|
||||
@@ -34,15 +34,21 @@ public final class StudioUiFactory {
|
||||
private ExecutionControllerFactory interactiveExecutions;
|
||||
private java.util.function.BiConsumer<p.studio.api.project.ProjectReference,p.studio.api.project.ProjectLocalStudioSetup> setupSaver;
|
||||
private p.studio.ui.javafx2.window.WindowResources interactiveResources;
|
||||
private p.studio.api.preferences.RuntimeSettingsStore runtimeSettings;
|
||||
private String initialRuntime;
|
||||
public void setRuntimeSettings(p.studio.api.preferences.RuntimeSettingsStore settings) { runtimeSettings=Objects.requireNonNull(settings); }
|
||||
public void enableInteractive(ExecutionControllerFactory factory,
|
||||
java.util.function.BiConsumer<p.studio.api.project.ProjectReference,p.studio.api.project.ProjectLocalStudioSetup> saver) {
|
||||
interactiveExecutions=Objects.requireNonNull(factory);setupSaver=Objects.requireNonNull(saver);
|
||||
}
|
||||
public void prepareInteractive(){interactiveResources=new p.studio.ui.javafx2.window.WindowResources();}
|
||||
public void prepareInteractive(){
|
||||
interactiveResources=new p.studio.ui.javafx2.window.WindowResources();
|
||||
initialRuntime=Objects.requireNonNull(runtimeSettings,"runtimeSettings").load();
|
||||
}
|
||||
public p.studio.ui.javafx2.window.StudioWindowCoordinator2 createInteractive(Stage stage){
|
||||
if(interactiveResources==null)throw new IllegalStateException("Interactive resources were not initialized");
|
||||
return new p.studio.ui.javafx2.window.StudioWindowCoordinator2(stage,projectCatalog,knownProjects,projectSessionFactory,
|
||||
Objects.requireNonNull(interactiveExecutions),setupSaver,executor,interactiveResources,languageCatalog,windowStateStore);
|
||||
Objects.requireNonNull(interactiveExecutions),setupSaver,executor,interactiveResources,languageCatalog,windowStateStore,runtimeSettings,initialRuntime);
|
||||
}
|
||||
private final ProjectCatalog projectCatalog;
|
||||
private final KnownProjects knownProjects;
|
||||
|
||||
@@ -14,10 +14,13 @@ public final class AssetBudgetInspection implements AssetBuildPreflight {
|
||||
private final Function<ProjectReference,ProjectLocalStudioSetup> setup;
|
||||
public AssetBudgetInspection(ObjectMapper json,PackerWorkspaceService packer,Function<ProjectReference,ProjectLocalStudioSetup> setup){this.packer=packer;this.profiles=new AssetCapacityProfiles(json);this.setup=setup;}
|
||||
@Override public AssetBudgets.Snapshot inspect(ProjectReference project) {
|
||||
return inspect(project,setup.apply(project));
|
||||
}
|
||||
@Override public AssetBudgets.Snapshot inspect(ProjectReference project,ProjectLocalStudioSetup effectiveSetup) {
|
||||
var context=new PackerProjectContext(project.name(),project.rootPath());
|
||||
return packer.withProject(context,()->{
|
||||
var plan=packer.planPackWorkspace(context);
|
||||
return new AssetBudgetPolicy().evaluate(AssetWorkspaceFiles.revision(project.rootPath()),profiles.select(setup.apply(project)),plan,
|
||||
return new AssetBudgetPolicy().evaluate(AssetWorkspaceFiles.revision(project.rootPath()),profiles.select(effectiveSetup),plan,
|
||||
plan.diagnostics().stream().map(d->AssetBatchDiagnostics.from(d,project.rootPath(),project.rootPath())).toList());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
package p.studio.app;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.*;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.scene.input.MouseButton;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.robot.Robot;
|
||||
import javafx.stage.Stage;
|
||||
import org.junit.jupiter.api.*;
|
||||
import p.studio.ui.javafx2.appearance.*;
|
||||
import p.studio.ui.javafx2.components.*;
|
||||
import p.studio.ui.javafx2.preferences.SettingsStore;
|
||||
import p.studio.ui.javafx2.window.WindowResources;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/** Real mouse and screen captures: Scene.snapshot alone can conceal a stale screen repaint. */
|
||||
@Tag("integration")
|
||||
class StudioControlsDesktopTest {
|
||||
static <T>T fx(Callable<T> action)throws Exception{var future=new FutureTask<>(action);Platform.runLater(future);return future.get(15,TimeUnit.SECONDS);}
|
||||
@BeforeAll static void toolkit()throws Exception{var ready=new CompletableFuture<Void>();Platform.startup(()->{Platform.setImplicitExit(false);ready.complete(null);});ready.get(15,TimeUnit.SECONDS);}
|
||||
@AfterAll static void stop(){Platform.exit();}
|
||||
static void pulses()throws Exception{
|
||||
var ready=new CountDownLatch(1);fx(()->{new AnimationTimer(){int n;public void handle(long now){if(++n==4){stop();ready.countDown();}}}.start();return null;});
|
||||
assertTrue(ready.await(5,TimeUnit.SECONDS));
|
||||
}
|
||||
static WindowResources resources(){
|
||||
var initial=PresentationSettings.defaults(Locale.ENGLISH);
|
||||
return new WindowResources(initial,new SettingsStore(){public PresentationSettings load(){return initial;}public void save(PresentationSettings value){}});
|
||||
}
|
||||
static void write(WritableImage image,String name)throws Exception{
|
||||
var buffer=new java.awt.image.BufferedImage((int)image.getWidth(),(int)image.getHeight(),java.awt.image.BufferedImage.TYPE_INT_ARGB);
|
||||
for(int y=0;y<buffer.getHeight();y++)for(int x=0;x<buffer.getWidth();x++)buffer.setRGB(x,y,image.getPixelReader().getArgb(x,y));
|
||||
Path file=Path.of(System.getProperty("studio.test.controlsCaptures"),name+".png");Files.createDirectories(file.getParent());javax.imageio.ImageIO.write(buffer,"png",file.toFile());
|
||||
}
|
||||
static WritableImage screen(Stage stage)throws Exception{return fx(()->{
|
||||
var point=stage.getScene().getRoot().localToScreen(0,0);
|
||||
return new Robot().getScreenCapture(null,point.getX(),point.getY(),stage.getScene().getWidth(),stage.getScene().getHeight(),true);
|
||||
});}
|
||||
static void awaitWindowPresentation(Stage stage)throws Exception{
|
||||
// Pulses alone do not wait for the native window compositor's show transition.
|
||||
// Observe stable screen pixels before sending input; never repaint to stabilize them.
|
||||
long previous=0,end=System.nanoTime()+TimeUnit.SECONDS.toNanos(5);int stable=0;
|
||||
while(System.nanoTime()<end){
|
||||
pulses();var image=screen(stage);long hash=1;
|
||||
for(int y=0;y<image.getHeight();y++)for(int x=0;x<image.getWidth();x++)hash=31*hash+image.getPixelReader().getArgb(x,y);
|
||||
stable=hash==previous?stable+1:0;if(stable==3)return;previous=hash;
|
||||
}
|
||||
fail("Native window presentation did not settle before mouse input");
|
||||
}
|
||||
static void click(ButtonBase button)throws Exception{
|
||||
fx(()->{var point=button.localToScreen(button.getWidth()/2,button.getHeight()/2);var robot=new Robot();robot.mouseMove(point);robot.mousePress(MouseButton.PRIMARY);return null;});pulses();
|
||||
fx(()->{new Robot().mouseRelease(MouseButton.PRIMARY);return null;});pulses();
|
||||
}
|
||||
@Test void rightAlignedSlotsStayStableThroughNativeClicksThemesAndTranslations()throws Exception{
|
||||
var resources=resources();var context=fx(resources::context);
|
||||
var play=fx(()->new StudioButton(context,"play.start",false));var pause=fx(()->new StudioToggle(context,"play.pause"));
|
||||
var info=fx(()->new Label("Ready"));
|
||||
var root=fx(()->{
|
||||
play.textProperty().unbind();pause.textProperty().unbind();
|
||||
play.setOnAction(e->{play.setText(context.text("play.stop"));info.setText("Preparing project — long status must not move the controls");});
|
||||
pause.setOnAction(e->pause.setText(context.text(pause.isSelected()?"play.resume":"play.pause")));
|
||||
var brand=new Menu("Prometeu Studio");brand.setGraphic(new StudioIcon());var navigation=new MenuBar(brand,new Menu("Project"));navigation.getStyleClass().add("studio-navigation");
|
||||
var bar=new p.studio.ui.javafx2.shell.ExecutionBar(context,navigation,play,pause);
|
||||
var tab=new Tab("Gameplay",new Label("Native tab fixture"));tab.setClosable(false);var tabs=new StudioTabs(tab);
|
||||
var pane=new BorderPane(tabs,new VBox(bar,info),null,null,null);context.attach(pane);return pane;
|
||||
});
|
||||
var stage=fx(()->{var value=new Stage();value.setAlwaysOnTop(true);value.setScene(new Scene(root,1200,460));value.show();return value;});
|
||||
try{
|
||||
awaitWindowPresentation(stage);
|
||||
for(Theme theme:Theme.values())for(var language:p.studio.ui.javafx2.i18n.StudioLanguage.values())for(double scale:new double[]{1,2}){
|
||||
fx(()->{context.update(new PresentationSettings(theme,language,Typeface.DEPARTURE,scale));play.setText(context.text("play.start"));pause.setSelected(false);pause.setText(context.text("play.pause"));info.setText("Ready");return null;});pulses();
|
||||
Bounds before=fx(()->play.localToScene(play.getBoundsInLocal())),other=fx(()->pause.localToScene(pause.getBoundsInLocal()));
|
||||
assertEquals(fx(()->root.getWidth()-12),other.getMaxX(),1,"Command pair must stay at the right padding");
|
||||
assertTrue(before.getMinX()>fx(()->root.getWidth()/2),"Commands must leave room for navigation on the left");
|
||||
click(play);click(pause);
|
||||
assertEquals(context.text("play.resume"),fx(pause::getText));
|
||||
Bounds after=fx(()->play.localToScene(play.getBoundsInLocal()));assertEquals(before.getMinX(),after.getMinX(),.1);assertEquals(before.getWidth(),after.getWidth(),.1);
|
||||
Bounds pauseAfter=fx(()->pause.localToScene(pause.getBoundsInLocal()));assertEquals(other.getMinX(),pauseAfter.getMinX(),.1);assertEquals(other.getWidth(),pauseAfter.getWidth(),.1);
|
||||
fx(()->{new Robot().mouseMove(root.localToScreen(10,root.getHeight()-10));return null;});pulses();
|
||||
var observed=screen(stage);String old=fx(root::getStyle);
|
||||
fx(()->{root.setStyle(old+"-fx-background-color: #41556b;");return null;});pulses();fx(()->{root.setStyle(old);return null;});pulses();var reference=screen(stage);
|
||||
int changed=0;
|
||||
for(int y=(int)before.getMinY()-6;y<before.getMaxY()+6;y++)for(int x=(int)before.getMinX()-6;x<other.getMaxX()+6;x++)
|
||||
if(x>=0&&y>=0&&x<observed.getWidth()&&y<observed.getHeight()&&observed.getPixelReader().getArgb(x,y)!=reference.getPixelReader().getArgb(x,y))changed++;
|
||||
if(changed!=0){write(observed,"stable-failure-observed");write(reference,"stable-failure-reference");}
|
||||
assertEquals(0,changed,"No stale screen pixels after mouse exit: "+theme+" "+language+" "+scale);
|
||||
write(observed,"stable-"+theme+"-"+language+"-"+scale);
|
||||
}
|
||||
fx(()->{stage.setWidth(680);return null;});pulses();
|
||||
Bounds a=fx(()->play.localToScene(play.getBoundsInLocal())),b=fx(()->pause.localToScene(pause.getBoundsInLocal()));
|
||||
assertTrue(a.getMinX()>=0&&b.getMaxX()<=fx(root::getWidth));
|
||||
assertEquals(fx(()->root.getWidth()-12),b.getMaxX(),1);
|
||||
Bounds navigation=fx(()->root.lookup(".studio-navigation").localToScene(root.lookup(".studio-navigation").getBoundsInLocal()));
|
||||
assertTrue(navigation.getMaxY()<=a.getMinY(),"Narrow large-text windows must put commands on a separate row");
|
||||
}finally{fx(()->{stage.hide();context.close();return null;});resources.close();}
|
||||
}
|
||||
@Test void nativeMouseProbeRecordsShiftAndScreenInvalidation()throws Exception{
|
||||
var resources=resources();var context=fx(resources::context);
|
||||
var play=fx(()->new StudioButton(context,"play.start",false));
|
||||
var pause=fx(()->new StudioToggle(context,"play.pause"));
|
||||
var information=fx(()->new Label("Ready"));
|
||||
var originalTooltip=fx(()->{var tooltip=new Tooltip("Play");tooltip.setShowDelay(javafx.util.Duration.millis(60));tooltip.setHideDelay(javafx.util.Duration.millis(100));play.setTooltip(tooltip);return tooltip;});
|
||||
var root=fx(()->{var flow=new FlowPane(12,10,new Label("Prometeu Studio"),play,pause,information);flow.setAlignment(Pos.CENTER);flow.setPadding(new Insets(40));
|
||||
var box=new BorderPane(flow);context.attach(box);return box;});
|
||||
var stage=fx(()->{var value=new Stage();value.setAlwaysOnTop(true);value.setScene(new Scene(root,1000,280));value.show();value.toFront();return value;});
|
||||
try{
|
||||
fx(()->{play.textProperty().unbind();play.setOnAction(e->{play.setText("Stop");information.setText("Preparing the project and native resources");play.setTooltip(new Tooltip("Stop"));});return null;});pulses();
|
||||
Bounds before=fx(()->play.localToScene(play.getBoundsInLocal()));
|
||||
fx(()->{var p=play.localToScreen(play.getWidth()/2,play.getHeight()/2);new Robot().mouseMove(p);return null;});Thread.sleep(180);pulses();
|
||||
boolean tooltipBefore=fx(originalTooltip::isShowing);write(screen(stage),"probe-hover");
|
||||
fx(()->{var p=play.localToScreen(play.getWidth()/2,play.getHeight()/2);var robot=new Robot();robot.mouseMove(p);robot.mousePress(MouseButton.PRIMARY);return null;});pulses();write(screen(stage),"probe-pressed");
|
||||
fx(()->{new Robot().mouseRelease(MouseButton.PRIMARY);return null;});pulses();
|
||||
Bounds after=fx(()->play.localToScene(play.getBoundsInLocal()));write(screen(stage),"probe-released");
|
||||
fx(()->{new Robot().mouseMove(root.localToScreen(10,root.getHeight()-10));return null;});pulses();var observed=screen(stage);write(observed,"probe-exit");
|
||||
String old=fx(root::getStyle);
|
||||
// Reference image only: request one whole-background repaint to detect stale pixels.
|
||||
fx(()->{root.setStyle(old+"-fx-background-color: #41556b;");return null;});pulses();
|
||||
fx(()->{root.setStyle(old);return null;});pulses();var reference=screen(stage);write(reference,"probe-repaint-reference");
|
||||
int changed=0;
|
||||
for(int y=Math.max(0,(int)before.getMinY()-8);y<Math.min(observed.getHeight(),before.getMaxY()+8);y++)
|
||||
for(int x=Math.max(0,(int)before.getMinX()-8);x<Math.min(observed.getWidth(),before.getMaxX()+8);x++)
|
||||
if(observed.getPixelReader().getArgb(x,y)!=reference.getPixelReader().getArgb(x,y))changed++;
|
||||
String facts="before="+before+"\nafter="+after+"\nchangedPixelsAfterFullRepaint="+changed+"\ntooltipBefore="+tooltipBefore+"\nretiredTooltipAfterExit="+fx(originalTooltip::isShowing)+"\n";
|
||||
System.out.println(facts);Files.writeString(Path.of(System.getProperty("studio.test.controlsCaptures"),"probe.txt"),facts);
|
||||
assertEquals("Stop",fx(play::getText),"Native mouse release must invoke the button");
|
||||
}finally{fx(()->{stage.hide();context.close();return null;});resources.close();}
|
||||
}
|
||||
}
|
||||
@@ -45,10 +45,11 @@ class StudioPlayDesktopTest {
|
||||
Path relative=source.relativize(file);if(relative.toString().startsWith(".")||relative.toString().startsWith("build"))continue;
|
||||
Path target=root.resolve(relative);if(Files.isDirectory(file))Files.createDirectories(target);else Files.copy(file,target);
|
||||
}}
|
||||
var resources=new WindowResources();
|
||||
var initial=p.studio.ui.javafx2.appearance.PresentationSettings.defaults(Locale.ENGLISH);
|
||||
var resources=new WindowResources(initial,new p.studio.ui.javafx2.preferences.SettingsStore(){public p.studio.ui.javafx2.appearance.PresentationSettings load(){return initial;}public void save(p.studio.ui.javafx2.appearance.PresentationSettings value){}});
|
||||
try(var app=new SpringApplicationBuilder(StudioApplicationConfiguration.class).web(WebApplicationType.NONE).headless(false).run()){
|
||||
var catalog=app.getBean(ProjectCatalog.class);var setups=app.getBean(ProjectLocalStudioSetupStore.class);
|
||||
var ref=catalog.openProject(root);setups.save(ref,new ProjectLocalStudioSetup(System.getProperty("studio.test.runtimeInstall"),null));
|
||||
var ref=catalog.openProject(root);setups.save(ref,new ProjectLocalStudioSetup(null,null));
|
||||
var access=app.getBean(ProjectAccessRegistry.class);var executor=app.getBean("studioExecutor",ExecutorService.class);
|
||||
var delayedPause=new java.util.concurrent.atomic.AtomicBoolean();
|
||||
var oldPause=new java.util.concurrent.atomic.AtomicReference<CompletableFuture<Void>>();
|
||||
@@ -76,21 +77,51 @@ class StudioPlayDesktopTest {
|
||||
var factory=new DefaultExecutionControllerFactory(app.getBean(p.studio.api.shipper.Shipper.class),
|
||||
gateway,app.getBean(p.studio.api.operation.OperationExecutor.class),access);
|
||||
var known=new KnownProjects(){public List<ProjectReference> listKnownProjects(){return List.of(ref);}public void remember(ProjectReference r){}public void forget(ProjectReference r){}};
|
||||
var runtimeSettings=new p.studio.core.project.preferences.JsonRuntimeSettingsStore(temporary.resolve("runtime-settings.json"),new ObjectMapper());
|
||||
runtimeSettings.save(System.getProperty("studio.test.runtimeInstall"));String globalRuntime=runtimeSettings.load();
|
||||
Stage stage=fx(Stage::new);
|
||||
var window=fx(()->new StudioWindowCoordinator2(stage,catalog,known,app.getBean(ProjectSessionFactory.class),factory,
|
||||
(project,setup)->{try(var lease=access.enterManual(project.rootPath())){setups.save(project,setup);}},executor,resources));
|
||||
(project,setup)->{try(var lease=access.enterManual(project.rootPath())){setups.save(project,setup);}},executor,resources,app.getBean(ProjectLanguageCatalog.class),new p.studio.core.project.preferences.JsonWindowStateStore(temporary.resolve("window-state.json"),new ObjectMapper()),runtimeSettings,globalRuntime));
|
||||
try{
|
||||
fx(()->{window.showLauncher();stage.toFront();stage.requestFocus();assertNotNull(stage.getScene().lookup("#studio-shell"));window.openProject(root);return null;});
|
||||
await(()->{try{return fx(()->window.projectSession()!=null);}catch(Exception e){throw new RuntimeException(e);}},()->"Project did not open");
|
||||
Supplier<String> facts=()->{try{capture(stage,"failure.png");return fx(()->"state="+window.projectSession().executionSession().snapshot().state()+" focused="+stage.isFocused()+" frames="+window.viewport().paintedFrames()+"\n"+((Label)stage.getScene().lookup("#studio-notice")).getText()+"\n"+((TextArea)stage.getScene().lookup("#execution-logs")).getText());}catch(Exception e){return e.toString();}};
|
||||
focus(stage);
|
||||
var probe=new Tab("Fixture view",new Label("Tab lifetime probe"));
|
||||
fx(()->{var tabs=(TabPane)stage.getScene().lookup("#project-tabs");tabs.getTabs().add(probe);tabs.getSelectionModel().select(probe);
|
||||
assertNull(tabs.lookup("#play"),"Global execution control must be outside tab content");return null;});
|
||||
fire(stage,"play");running(window,stage,facts);
|
||||
fx(()->{var tabs=(TabPane)stage.getScene().lookup("#project-tabs");assertEquals("gameplay-tab",tabs.getSelectionModel().getSelectedItem().getId());
|
||||
tabs.getSelectionModel().select(probe);return null;});Thread.sleep(200);
|
||||
assertEquals(ExecutionState.RUNNING,fx(()->window.projectSession().executionSession().snapshot().state()),"Changing tabs must not stop or pause the project session");
|
||||
fx(()->{var tabs=(TabPane)stage.getScene().lookup("#project-tabs");tabs.getSelectionModel().select(0);tabs.getTabs().remove(probe);return null;});
|
||||
await(()->{try{return fx(()->window.viewport().paintedFrames()>3);}catch(Exception e){throw new RuntimeException(e);}},facts);
|
||||
fx(()->{assertTrue(stage.getScene().lookup("#runtime-path").isDisabled());return null;});
|
||||
fx(()->{assertNull(stage.getScene().lookup("#runtime-path"));assertTrue(projectSettings(stage).isDisable());return null;});
|
||||
assertThrows(p.studio.api.automation.ControlDeniedException.class,()->access.enterManual(root));
|
||||
fx(()->{ComboBox<Integer> zoom=(ComboBox<Integer>)stage.getScene().lookup("#viewport-zoom");zoom.setValue(4);
|
||||
var image=(ImageView)stage.getScene().lookup("#game-image");assertEquals(2560,image.getFitWidth());assertFalse(image.isSmooth());
|
||||
zoom.setValue(2);assertEquals(1280,image.getFitWidth());zoom.setValue(1);assertEquals(640,image.getFitWidth());return null;});
|
||||
assertNull(setups.load(ref).prometeuRuntimePath(),"Inherited default must remain null in project storage");
|
||||
capture(stage,"play-default.png");
|
||||
assertFalse(fx(()->((MenuBar)stage.getScene().lookup("#studio-menus")).getMenus().getFirst().isShowing()),"Native divider drag requires the menu to be closed");
|
||||
double fittedBefore=fx(()->window.viewport().scale());
|
||||
double logsBefore=fx(()->((TextArea)stage.getScene().lookup("#execution-logs")).getHeight());
|
||||
String footerBefore=fx(()->((Label)stage.getScene().lookup("#studio-footer")).getText());
|
||||
dragGameplayDivider(stage,.35);
|
||||
await(()->{try{return fx(()->window.viewport().scale()<fittedBefore&&((TextArea)stage.getScene().lookup("#execution-logs")).getHeight()>logsBefore);}catch(Exception e){throw new RuntimeException(e);}},facts);
|
||||
fx(()->{var image=(ImageView)stage.getScene().lookup("#game-image");
|
||||
assertEquals(window.viewport().scale(),image.getFitWidth()/image.getImage().getWidth(),.001);
|
||||
assertEquals(window.viewport().scale(),image.getFitHeight()/image.getImage().getHeight(),.001);
|
||||
assertNotEquals(footerBefore,((Label)stage.getScene().lookup("#studio-footer")).getText());
|
||||
assertEquals(ExecutionState.RUNNING,window.projectSession().executionSession().snapshot().state());return null;});
|
||||
capture(stage,"play-logs-expanded.png");
|
||||
fx(()->{var manual=(CheckBox)stage.getScene().lookup("#manual-scale");manual.fire();
|
||||
var slider=(Slider)stage.getScene().lookup("#game-scale");slider.setValue(150);
|
||||
var image=(ImageView)stage.getScene().lookup("#game-image");assertEquals(960,image.getFitWidth(),1);assertFalse(image.isSmooth());
|
||||
return null;});
|
||||
dragGameplayDivider(stage,.6);
|
||||
fx(()->{assertEquals(1.5,window.viewport().scale(),.001,"Divider drag must preserve manual scale");
|
||||
var manual=(CheckBox)stage.getScene().lookup("#manual-scale");var slider=(Slider)stage.getScene().lookup("#game-scale");
|
||||
var image=(ImageView)stage.getScene().lookup("#game-image");assertEquals(960,image.getFitWidth(),1);
|
||||
slider.setValue(400);assertEquals(2560,image.getFitWidth(),1);manual.fire();return null;});
|
||||
dragGameplayDivider(stage,.8);
|
||||
// Deliver a real key edge through the viewport; Pong leaves its static menu.
|
||||
// Zoom popup/native activation can transfer desktop focus. Establish the
|
||||
// input precondition explicitly; the later focus-loss checks never resume.
|
||||
@@ -107,17 +138,25 @@ class StudioPlayDesktopTest {
|
||||
fx(()->{stage.getScene().lookup("#game-surface").fireEvent(new KeyEvent(KeyEvent.KEY_RELEASED,"a","a",KeyCode.A,false,false,false,false));return null;});
|
||||
}
|
||||
fire(stage,"pause");state(window,ExecutionState.PAUSED,facts);
|
||||
fx(()->{var button=(ToggleButton)stage.getScene().lookup("#pause");
|
||||
assertEquals("Resume",button.getText());assertEquals(button.getText(),button.getAccessibleText());
|
||||
assertEquals(button.getText(),button.getTooltip().getText());return null;});
|
||||
long paused=fx(()->window.viewport().lastFrameId());Thread.sleep(200);
|
||||
assertEquals(paused,fx(()->window.viewport().lastFrameId()));fire(stage,"resume");running(window,stage,facts);
|
||||
double pausedScale=fx(()->window.viewport().scale());dragGameplayDivider(stage,.45);
|
||||
assertTrue(fx(()->window.viewport().scale()<pausedScale),"Automatic fit must update even without new frames while paused");
|
||||
assertEquals(ExecutionState.PAUSED,fx(()->window.projectSession().executionSession().snapshot().state()));
|
||||
capture(stage,"paused-logs-expanded.png");dragGameplayDivider(stage,.8);
|
||||
assertEquals(paused,fx(()->window.viewport().lastFrameId()));fire(stage,"pause");running(window,stage,facts);
|
||||
fx(()->{assertEquals("Pause",((ToggleButton)stage.getScene().lookup("#pause")).getText());return null;});
|
||||
// A window owned by Studio is not an application switch.
|
||||
Stage owned=fx(()->{var s=new Stage();s.initOwner(stage);s.setScene(new javafx.scene.Scene(new Label("Studio dialog"),240,120));s.show();s.requestFocus();return s;});Thread.sleep(250);
|
||||
assertEquals(ExecutionState.RUNNING,fx(()->window.projectSession().executionSession().snapshot().state()));
|
||||
fx(()->{owned.hide();stage.requestFocus();stage.setIconified(true);return null;});state(window,ExecutionState.PAUSED,facts);
|
||||
fx(()->{stage.setIconified(false);stage.requestFocus();return null;});Thread.sleep(200);
|
||||
assertEquals(ExecutionState.PAUSED,fx(()->window.projectSession().executionSession().snapshot().state()));fire(stage,"resume");running(window,stage,facts);
|
||||
assertEquals(ExecutionState.PAUSED,fx(()->window.projectSession().executionSession().snapshot().state()));fire(stage,"pause");running(window,stage,facts);
|
||||
Stage other=fx(()->{var s=new Stage();s.setTitle("Other application focus probe");s.setScene(new javafx.scene.Scene(new Label("Focus probe"),300,150));s.show();s.requestFocus();return s;});state(window,ExecutionState.PAUSED,facts);
|
||||
fx(()->{other.hide();stage.requestFocus();return null;});Thread.sleep(200);
|
||||
assertEquals(ExecutionState.PAUSED,fx(()->window.projectSession().executionSession().snapshot().state()));fire(stage,"resume");running(window,stage,facts);
|
||||
assertEquals(ExecutionState.PAUSED,fx(()->window.projectSession().executionSession().snapshot().state()));fire(stage,"pause");running(window,stage,facts);
|
||||
capture(stage,"play.png");
|
||||
if(Boolean.getBoolean("studio.test.playStress")){
|
||||
var process=runtime();long runtimeCpu=cpuNanos(process);
|
||||
@@ -137,28 +176,28 @@ class StudioPlayDesktopTest {
|
||||
long afterFreeze=fx(()->window.viewport().lastFrameId());
|
||||
System.out.println("FX_FREEZE_FRAME_IDS="+frame+","+afterFreeze);
|
||||
assertTrue(afterFreeze>frame+15,()->"Runtime must advance while FX is blocked: "+frame+" -> "+afterFreeze+"\n"+facts.get());
|
||||
for(int i=0;i<20;i++){fire(stage,"stop");state(window,ExecutionState.STOPPED,facts);Thread.sleep(130);
|
||||
for(int i=0;i<20;i++){fire(stage,"play");state(window,ExecutionState.STOPPED,facts);Thread.sleep(130);
|
||||
assertEquals(0,runtimeCount());assertEquals(0,heartbeatThreads());
|
||||
fire(stage,"play");running(window,stage,facts);Thread.sleep(50);
|
||||
assertEquals(1,runtimeCount());assertEquals(1,heartbeatThreads());}
|
||||
System.out.println("PLAY_STOP_CYCLES=20");
|
||||
}
|
||||
fire(stage,"stop");state(window,ExecutionState.STOPPED,facts);
|
||||
await(()->{try{return fx(()->!stage.getScene().lookup("#runtime-path").isDisabled());}catch(Exception e){throw new RuntimeException(e);}},facts);
|
||||
fire(stage,"play");state(window,ExecutionState.STOPPED,facts);
|
||||
await(()->{try{return fx(()->!projectSettings(stage).isDisable());}catch(Exception e){throw new RuntimeException(e);}},facts);
|
||||
try(var lease=access.enterManual(root)){}
|
||||
assertFalse(Files.exists(root.resolve(".codex")),"Play must not prepare an AI client");
|
||||
assertFalse(Files.exists(root.resolve("build.pmc")));
|
||||
fire(stage,"play");running(window,stage,facts);
|
||||
delayedPause.set(true);fire(stage,"pause");
|
||||
await(()->oldPause.get()!=null,facts);
|
||||
fire(stage,"stop");state(window,ExecutionState.STOPPED,facts);
|
||||
fire(stage,"play");state(window,ExecutionState.STOPPED,facts);
|
||||
fire(stage,"play");running(window,stage,facts);
|
||||
oldPause.get().completeExceptionally(new java.io.IOException("obsolete-pause-result"));
|
||||
Thread.sleep(200);
|
||||
assertFalse(fx(()->((Label)stage.getScene().lookup("#studio-notice")).getText().contains("obsolete-pause-result")),
|
||||
"An old command must not replace a new execution's feedback");
|
||||
runtime().destroyForcibly();state(window,ExecutionState.RUNTIME_FAILED,facts);
|
||||
await(()->{try{return fx(()->!stage.getScene().lookup("#runtime-path").isDisabled());}catch(Exception e){throw new RuntimeException(e);}},facts);
|
||||
await(()->{try{return fx(()->!projectSettings(stage).isDisable());}catch(Exception e){throw new RuntimeException(e);}},facts);
|
||||
assertTrue(fx(()->((TextArea)stage.getScene().lookup("#execution-logs")).getText().contains("Runtime")));
|
||||
fire(stage,"play");running(window,stage,facts);
|
||||
fx(()->{window.requestCloseProject();return null;});
|
||||
@@ -168,7 +207,8 @@ class StudioPlayDesktopTest {
|
||||
}finally{fx(window::closeAsync).toCompletableFuture().get(15,TimeUnit.SECONDS);}
|
||||
}
|
||||
}
|
||||
static void fire(Stage stage,String id)throws Exception{fx(()->{Button button=(Button)stage.getScene().lookup("#"+id);assertFalse(button.isDisabled(),id+" disabled");button.fire();return null;});}
|
||||
static MenuItem projectSettings(Stage stage){return ((MenuBar)stage.getScene().lookup("#studio-menus")).getMenus().stream().flatMap(m->m.getItems().stream()).filter(i->"project-settings".equals(i.getId())).findFirst().orElseThrow();}
|
||||
static void fire(Stage stage,String id)throws Exception{fx(()->{ButtonBase button=(ButtonBase)stage.getScene().lookup("#"+id);assertFalse(button.isDisabled(),id+" disabled");button.fire();return null;});}
|
||||
static void state(StudioWindowCoordinator2 w,ExecutionState expected,Supplier<String> facts)throws Exception{
|
||||
await(()->{try{return fx(()->w.projectSession().executionSession().snapshot().state()==expected);}catch(Exception e){throw new RuntimeException(e);}},facts);
|
||||
Thread.sleep(130);
|
||||
@@ -176,12 +216,26 @@ class StudioPlayDesktopTest {
|
||||
static void running(StudioWindowCoordinator2 w,Stage stage,Supplier<String> facts)throws Exception{
|
||||
focus(stage);
|
||||
await(()->{try{return fx(()->{var state=w.projectSession().executionSession().snapshot().state();
|
||||
if(state==ExecutionState.PAUSED){stage.requestFocus();((Button)stage.getScene().lookup("#resume")).fire();}
|
||||
if(state==ExecutionState.PAUSED){stage.requestFocus();((ToggleButton)stage.getScene().lookup("#pause")).fire();}
|
||||
return state==ExecutionState.RUNNING && stage.isFocused();});}catch(Exception e){throw new RuntimeException(e);}},facts);Thread.sleep(150);
|
||||
}
|
||||
static void focus(Stage stage)throws Exception{fx(()->{stage.setIconified(false);stage.toFront();stage.requestFocus();
|
||||
var point=stage.getScene().getRoot().localToScreen(10,10);
|
||||
var header=stage.getScene().lookup("#studio-header");var bounds=header.getBoundsInLocal();
|
||||
var point=header.localToScreen(bounds.getCenterX(),bounds.getCenterY());
|
||||
var robot=new javafx.scene.robot.Robot();robot.mouseMove(point);robot.mouseClick(MouseButton.PRIMARY);return null;});Thread.sleep(150);}
|
||||
static void dragGameplayDivider(Stage stage,double fraction)throws Exception{
|
||||
var start=fx(()->{var split=(SplitPane)stage.getScene().lookup("#gameplay-split");var divider=split.lookup(".split-pane-divider");
|
||||
assertNotNull(divider);assertTrue(divider.getBoundsInLocal().getHeight()>=6,"Divider must have a usable drag target");
|
||||
return divider.localToScreen(divider.getBoundsInLocal().getCenterX(),divider.getBoundsInLocal().getCenterY());});
|
||||
var end=fx(()->{var split=(SplitPane)stage.getScene().lookup("#gameplay-split");return split.localToScreen(split.getWidth()/2,split.getHeight()*fraction);});
|
||||
// Drain the initial MOUSE_MOVED before pressing; a late move ends JavaFX's drag capture.
|
||||
var robot=fx(javafx.scene.robot.Robot::new);fx(()->{robot.mouseMove(start);return null;});Thread.sleep(150);
|
||||
fx(()->{robot.mousePress(MouseButton.PRIMARY);return null;});
|
||||
try{Thread.sleep(80);for(int i=1;i<=24;i++){
|
||||
double t=i/24.;fx(()->{robot.mouseMove(start.getX()+(end.getX()-start.getX())*t,start.getY()+(end.getY()-start.getY())*t);return null;});Thread.sleep(15);
|
||||
}}finally{fx(()->{robot.mouseRelease(MouseButton.PRIMARY);return null;});}
|
||||
Thread.sleep(150);
|
||||
}
|
||||
static void capture(Stage stage,String name)throws Exception{fx(()->{
|
||||
var image=stage.getScene().snapshot(null);var output=new java.awt.image.BufferedImage((int)image.getWidth(),(int)image.getHeight(),java.awt.image.BufferedImage.TYPE_INT_ARGB);
|
||||
for(int y=0;y<output.getHeight();y++)for(int x=0;x<output.getWidth();x++)output.setRGB(x,y,image.getPixelReader().getArgb(x,y));
|
||||
@@ -201,7 +255,7 @@ class StudioPlayDesktopTest {
|
||||
return (long)(seconds*1e9);
|
||||
}
|
||||
|
||||
@Test void viewportCopiesStablePixelsAndInvertsZoomWithoutClampingOutsideTouches()throws Exception{
|
||||
@Test void viewportFitsAndInvertsManualScaleWithoutClampingOutsideTouches()throws Exception{
|
||||
var input=new java.util.concurrent.atomic.AtomicReference<>(ExecutionInput.NEUTRAL);
|
||||
byte[] pixels=new byte[4*2*4];for(int i=0;i<pixels.length;i+=4){pixels[i+2]=(byte)255;pixels[i+3]=(byte)255;}
|
||||
var frame=new java.util.concurrent.atomic.AtomicReference<>(new ExecutionFrame(4,2,1,1,pixels,()->{}));
|
||||
@@ -214,7 +268,12 @@ class StudioPlayDesktopTest {
|
||||
Stage stage=fx(()->{var s=new Stage();s.setScene(new javafx.scene.Scene(viewport,500,300));s.show();return s;});
|
||||
try{
|
||||
await(()->{try{return fx(()->viewport.paintedFrames()==1);}catch(Exception e){throw new RuntimeException(e);}},()->"Frame was not painted");
|
||||
fx(()->{viewport.zoom(4);stage.getScene().getRoot().applyCss();stage.getScene().getRoot().layout();
|
||||
fx(()->{assertFalse(viewport.manual());
|
||||
ImageView auto=(ImageView)stage.getScene().lookup("#game-image");assertTrue(auto.getFitWidth()>16,"Auto fit must enlarge to the available surface");
|
||||
viewport.setManual(true);viewport.setScale(1.5);stage.getScene().getRoot().applyCss();stage.getScene().getRoot().layout();
|
||||
assertEquals(6,auto.getFitWidth());pointer(auto,MouseEvent.MOUSE_PRESSED,3.1,1.6);assertEquals(new ExecutionInput(4096,2,1),input.get());
|
||||
pointer(auto,MouseEvent.MOUSE_RELEASED,30,30);assertEquals(0,input.get().buttons());
|
||||
viewport.setScale(4);stage.getScene().getRoot().layout();
|
||||
ImageView image=(ImageView)stage.getScene().lookup("#game-image");assertEquals(0xffff0000,image.getImage().getPixelReader().getArgb(1,1));
|
||||
assertEquals(16,image.getFitWidth());
|
||||
pointer(image,MouseEvent.MOUSE_PRESSED,6,6);assertEquals(new ExecutionInput(4096,1,1),input.get());
|
||||
@@ -224,7 +283,7 @@ class StudioPlayDesktopTest {
|
||||
pointer(image,MouseEvent.MOUSE_RELEASED,30,30);assertEquals(0,input.get().buttons());
|
||||
var surface=stage.getScene().lookup("#game-surface");
|
||||
surface.fireEvent(new KeyEvent(KeyEvent.KEY_PRESSED,"a","a",KeyCode.A,false,false,false,false));assertEquals(16,input.get().buttons());
|
||||
viewport.neutralize();assertEquals(0,input.get().buttons());return null;});
|
||||
viewport.neutralize();assertEquals(0,input.get().buttons());viewport.setManual(false);assertTrue(viewport.scale()>4);return null;});
|
||||
}finally{fx(()->{viewport.close();stage.hide();return null;});}
|
||||
}
|
||||
static void pointer(ImageView image,javafx.event.EventType<MouseEvent> type,double x,double y){
|
||||
|
||||
@@ -45,6 +45,162 @@ class StudioProjectsDesktopTest {
|
||||
static void fire(Stage stage,String id)throws Exception {fx(()->{var b=(Button)stage.getScene().lookup("#"+id);assertNotNull(b,id);assertFalse(b.isDisabled(),id);b.fire();return null;});}
|
||||
static Stage wizard()throws Exception {return fx(()->(Stage)Window.getWindows().stream().filter(w->w.isShowing()&&w.getScene().lookup("#wizard-name")!=null).findFirst().orElseThrow());}
|
||||
static Stage shield()throws Exception {return fx(()->(Stage)Window.getWindows().stream().filter(w->w.isShowing()&&w.getScene().lookup("#loading-phase")!=null).findFirst().orElseThrow());}
|
||||
static Stage settings()throws Exception {return fx(()->(Stage)Window.getWindows().stream().filter(w->w.isShowing()&&w.getScene().lookup("#settings-dialog")!=null).findFirst().orElseThrow());}
|
||||
|
||||
private record Harness(StudioWindowCoordinator2 window,Stage stage,ExecutorService worker) implements AutoCloseable {
|
||||
@Override public void close()throws Exception {fx(window::closeAsync).toCompletableFuture().get(15,TimeUnit.SECONDS);worker.shutdown();assertTrue(worker.awaitTermination(10,TimeUnit.SECONDS));}
|
||||
}
|
||||
private Harness harness(ProjectCatalog catalog,KnownProjects known,ProjectLocalStudioSetupStore setups,
|
||||
WindowStateStore windows,RuntimeSettingsStore runtimes)throws Exception {
|
||||
var initial=PresentationSettings.defaults(Locale.ENGLISH);
|
||||
var resources=new WindowResources(initial,new SettingsStore(){public PresentationSettings load(){return initial;}public void save(PresentationSettings value){assertFalse(Platform.isFxApplicationThread());}});
|
||||
var executor=Executors.newFixedThreadPool(3);
|
||||
ProjectSessionFactory sessions=new ProjectSessionFactory(){
|
||||
public ProjectSession open(ProjectReference ref){throw new AssertionError("editor");}
|
||||
public ProjectSession openForPlay(ProjectReference ref){
|
||||
assertFalse(Platform.isFxApplicationThread());var state=new DefaultExecutionSession();var setup=setups.load(ref);
|
||||
return (ProjectSession)Proxy.newProxyInstance(getClass().getClassLoader(),new Class[]{ProjectSession.class},(proxy,method,args)->switch(method.getName()){
|
||||
case "projectReference"->ref;case "projectLocalStudioSetup"->setup;case "executionSession"->state;
|
||||
case "close"->{state.close();yield null;}default->throw new AssertionError(method.getName());
|
||||
});
|
||||
}
|
||||
};
|
||||
String global=runtimes.load();Stage stage=fx(Stage::new);
|
||||
var window=fx(()->new StudioWindowCoordinator2(stage,catalog,known,sessions,null,setups::save,executor,resources,()->List.of(),windows,runtimes,global));
|
||||
fx(()->{window.showLauncher();return null;});await(()->fx(()->window.launcherStage().isShowing()));
|
||||
return new Harness(window,stage,executor);
|
||||
}
|
||||
private static void open(Harness harness,ProjectReference project)throws Exception {
|
||||
fx(()->{harness.window.openProject(project.rootPath());return null;});await(()->fx(()->harness.window.projectSession()!=null));
|
||||
}
|
||||
private static void closeProject(Harness harness)throws Exception {
|
||||
fx(()->{harness.window.requestCloseProject();return null;});await(()->fx(()->harness.window.projectSession()==null&&harness.window.launcherStage().isShowing()));
|
||||
}
|
||||
@Test void projectChromeKeepsEqualStripsAndContextualFooterAcrossThemesAndScales()throws Exception{
|
||||
var mapper=new ObjectMapper();var setups=new ProjectLocalStudioSetupStore(mapper);
|
||||
var catalog=new ProjectCatalogService(temporary.resolve("projects"),mapper,setups);
|
||||
var known=new KnownProjectsService(temporary.resolve("known.txt"),catalog);
|
||||
var project=catalog.createProject(new ProjectCreationRequest("A long project name to exercise ellipsis",catalog.projectsRoot(),"pbs",1,ProjectTarget.Game,"src",4,null));known.remember(project);
|
||||
var windows=new p.studio.core.project.preferences.JsonWindowStateStore(temporary.resolve("windows.json"),mapper);
|
||||
RuntimeSettingsStore runtimes=new RuntimeSettingsStore(){public String load(){return null;}public void save(String path){}};
|
||||
try(var h=harness(catalog,known,setups,windows,runtimes)){
|
||||
open(h,project);
|
||||
for(Theme theme:Theme.values())for(StudioLanguage language:StudioLanguage.values())for(double scale:new double[]{1,2}){
|
||||
fx(()->{h.window.openPreferences();return null;});Stage preferences=settings();
|
||||
fx(()->{((ComboBox<Theme>)preferences.getScene().lookup("#theme-select")).setValue(theme);
|
||||
((ComboBox<StudioLanguage>)preferences.getScene().lookup("#language-select")).setValue(language);
|
||||
((ComboBox<Double>)preferences.getScene().lookup("#scale-select")).setValue(scale);return null;});
|
||||
fire(preferences,"settings-apply");await(()->fx(()->!preferences.isShowing()));
|
||||
for(double width:new double[]{1200,680}){
|
||||
fx(()->{h.stage.setWidth(width);h.stage.setHeight(width==680?480:850);return null;});
|
||||
capture(h.stage,"chrome-"+theme+"-"+language+"-"+scale+"-"+width);
|
||||
fx(()->{var scene=h.stage.getScene();var header=(javafx.scene.layout.Region)scene.lookup("#studio-header");var footer=(Label)scene.lookup("#studio-footer");
|
||||
assertEquals(header.getHeight(),footer.getHeight(),.1);
|
||||
assertEquals(scene.getHeight(),footer.localToScene(0,footer.getHeight()).getY(),1);
|
||||
var play=scene.lookup("#play").localToScene(scene.lookup("#play").getBoundsInLocal());
|
||||
var pause=scene.lookup("#pause").localToScene(scene.lookup("#pause").getBoundsInLocal());
|
||||
assertEquals(scene.getWidth()-12,pause.getMaxX(),1);
|
||||
var navigation=scene.lookup("#studio-menus").localToScene(scene.lookup("#studio-menus").getBoundsInLocal());
|
||||
assertTrue(navigation.getMaxY()<=play.getMinY()||navigation.getMaxX()+12<=play.getMinX(),"Menus and execution must not overlap");
|
||||
assertTrue(play.getMinX()>=0&&pause.getMaxX()<=scene.getWidth());
|
||||
assertTrue(header.localToScene(0,0).getY()>=play.getMaxY());
|
||||
var workspace=(javafx.scene.layout.Region)scene.lookup("#empty-workspace");
|
||||
var workspaceBounds=workspace.localToScene(workspace.getBoundsInLocal());
|
||||
double above=workspaceBounds.getMinY()-header.localToScene(0,header.getHeight()).getY();
|
||||
double below=footer.localToScene(0,0).getY()-workspaceBounds.getMaxY();
|
||||
assertTrue(above>0&&below>0,"Workspace needs breathing room above and below");
|
||||
assertEquals(above,below,1,"Workspace must have balanced vertical spacing");
|
||||
assertNull(workspace.getShape(),"Workspace must not have the outer decorative silhouette");
|
||||
assertTrue(workspace.getBorder()==null||workspace.getBorder().getStrokes().isEmpty(),"Workspace must not draw an outer border");
|
||||
assertTrue(workspace.getBackground()==null||workspace.getBackground().getFills().size()<=1,"Workspace must not retain the layered panel bevel");
|
||||
var menu=((MenuBar)scene.lookup("#studio-menus")).getMenus().getFirst();assertEquals("Prometeu Studio",menu.getText());assertNotNull(menu.getGraphic());
|
||||
var tabs=(TabPane)scene.lookup("#project-tabs");assertTrue(tabs.getStyleClass().contains("studio-tabs"));
|
||||
assertTrue(tabs.lookupAll(".tab").stream().filter(n->n instanceof javafx.scene.layout.Region).allMatch(n->((javafx.scene.layout.Region)n).getShape()!=null));
|
||||
var split=(SplitPane)scene.lookup("#gameplay-split");assertSame(split,tabs.getTabs().getFirst().getContent());
|
||||
assertEquals(javafx.geometry.Orientation.VERTICAL,split.getOrientation());
|
||||
assertNotNull(split.lookup("#execution-logs"));assertNotNull(split.lookup("#play-viewport"));
|
||||
var outline=scene.lookup("#tab-content-outline");assertTrue(outline.isVisible());
|
||||
assertTrue(outline.isMouseTransparent());assertFalse(outline.isManaged());
|
||||
var frame=outline.localToScene(outline.getBoundsInLocal());
|
||||
var contents=split.localToScene(split.getLayoutBounds());
|
||||
assertTrue(frame.getMinX()<=contents.getMinX()&&frame.getMaxX()>=contents.getMaxX(),"Frame must span the content width");
|
||||
assertTrue(frame.getMinY()<=contents.getMinY()&&frame.getMaxY()>=contents.getMaxY(),"Frame must enclose game and logs");
|
||||
return null;});
|
||||
}
|
||||
}
|
||||
var unknown=fx(()->{var tabs=(TabPane)h.stage.getScene().lookup("#project-tabs");var footer=(p.studio.ui.javafx2.shell.TabStatusFooter)h.stage.getScene().lookup("#studio-footer");
|
||||
var empty=new Tab("Fixture view");tabs.getTabs().add(empty);tabs.getSelectionModel().select(empty);assertEquals("",footer.getText());
|
||||
var information=new javafx.beans.property.SimpleStringProperty("Fixture status");footer.information(empty,information);assertEquals("Fixture status",footer.getText());
|
||||
information.set("Updated status");assertEquals("Updated status",footer.getText());return empty;});
|
||||
capture(h.stage,"empty-tab");
|
||||
fx(()->{assertFalse(h.stage.getScene().lookup("#tab-content-outline").isVisible(),"Empty tab must not keep the previous outline");
|
||||
((TabPane)h.stage.getScene().lookup("#project-tabs")).getTabs().remove(unknown);
|
||||
assertTrue(((Label)h.stage.getScene().lookup("#studio-footer")).getText().startsWith("Gameplay"));return null;});
|
||||
capture(h.stage,"restored-gameplay-tab");
|
||||
assertTrue(fx(()->h.stage.getScene().lookup("#tab-content-outline").isVisible()));
|
||||
var execution=fx(()->h.window.projectSession().executionSession());
|
||||
fx(()->{execution.beginPreparationCycle();execution.transitionToConnecting();execution.transitionToRunning();return null;});
|
||||
await(()->fx(()->((ToggleButton)h.stage.getScene().lookup("#pause")).getText().equals("Pause")));
|
||||
var before=fx(()->h.stage.getScene().lookup("#pause").localToScene(h.stage.getScene().lookup("#pause").getBoundsInLocal()));
|
||||
fx(()->{execution.transitionToPausing();execution.transitionToPaused();return null;});await(()->fx(()->((ToggleButton)h.stage.getScene().lookup("#pause")).getText().equals("Resume")));
|
||||
var after=fx(()->h.stage.getScene().lookup("#pause").localToScene(h.stage.getScene().lookup("#pause").getBoundsInLocal()));
|
||||
assertEquals(before.getMinX(),after.getMinX(),.1);assertEquals(before.getWidth(),after.getWidth(),.1);
|
||||
fx(()->{execution.transitionToResuming();execution.transitionToRunning();execution.transitionToStopping();execution.transitionToStopped();return null;});
|
||||
}
|
||||
}
|
||||
@Test void geometryAndSettingsSurviveCoordinatorRestartAndKeepScopesSeparate()throws Exception {
|
||||
var mapper=new ObjectMapper();var setups=new ProjectLocalStudioSetupStore(mapper);
|
||||
var catalog=new ProjectCatalogService(temporary.resolve("projects"),mapper,setups);
|
||||
var known=new KnownProjectsService(temporary.resolve("known.txt"),catalog);
|
||||
var a=catalog.createProject(new ProjectCreationRequest("A",catalog.projectsRoot(),"pbs",1,ProjectTarget.Game,"src",4,null));
|
||||
var b=catalog.createProject(new ProjectCreationRequest("B",catalog.projectsRoot(),"pbs",1,ProjectTarget.Game,"src",4,null));known.remember(a);known.remember(b);
|
||||
var manifest=(com.fasterxml.jackson.databind.node.ObjectNode)mapper.readTree(a.rootPath().resolve("prometeu.json").toFile());
|
||||
manifest.put("memcard_slots",1);mapper.writeValue(a.rootPath().resolve("prometeu.json").toFile(),manifest);
|
||||
Path file=temporary.resolve("windows.json");
|
||||
var windows=new p.studio.core.project.preferences.JsonWindowStateStore(file,mapper);
|
||||
var runtimes=new p.studio.core.project.preferences.JsonRuntimeSettingsStore(temporary.resolve("runtime.json"),mapper);
|
||||
Path installation=Files.createDirectories(temporary.resolve("runtime"));
|
||||
assertTrue(Files.writeString(installation.resolve(System.getProperty("os.name").startsWith("Windows")?"prometeu-runtime.exe":"prometeu-runtime"),"fixture").toFile().setExecutable(true));
|
||||
try(var first=harness(catalog,known,setups,windows,runtimes)){
|
||||
fx(()->{first.window.launcherStage().setWidth(880);first.window.launcherStage().setHeight(610);first.window.openPreferences();return null;});
|
||||
Stage draft=settings();fx(()->{((TextField)draft.getScene().lookup("#global-runtime-path")).setText(installation.toString());return null;});
|
||||
fire(draft,"settings-cancel");assertNull(runtimes.load(),"Cancel must not publish the runtime");
|
||||
fx(()->{first.window.openPreferences();return null;});Stage applied=settings();
|
||||
fx(()->{((TextField)applied.getScene().lookup("#global-runtime-path")).setText(installation.toString());return null;});
|
||||
fire(applied,"settings-apply");await(()->fx(()->!applied.isShowing()));assertEquals(installation.toString(),runtimes.load());
|
||||
open(first,a);fx(()->{first.stage.setWidth(1040);first.stage.setHeight(730);first.window.openProjectSettings(false);return null;});
|
||||
Stage config=settings();fx(()->{assertTrue(((CheckBox)config.getScene().lookup("#runtime-inherit")).isSelected());
|
||||
assertTrue(((Label)config.getScene().lookup("#effective-runtime")).getText().contains(installation.toString()));return null;});
|
||||
fire(config,"settings-apply");await(()->fx(()->!config.isShowing()));assertNull(setups.load(a).prometeuRuntimePath());
|
||||
fire(first.stage,"play");assertTrue(fx(()->first.stage.getScene().lookup("#configure-action").isVisible()),"Missing save must lead to settings before starting execution");
|
||||
fire(first.stage,"configure-action");Stage saving=settings();
|
||||
fx(()->{var discard=(CheckBox)saving.getScene().lookup("#disposable-save");assertFalse(discard.isSelected());discard.setSelected(true);return null;});
|
||||
fire(saving,"settings-apply");await(()->fx(()->!saving.isShowing()));assertNull(setups.load(a).memcardPath());
|
||||
closeProject(first);open(first,b);fx(()->{first.stage.setWidth(820);first.stage.setHeight(620);return null;});closeProject(first);
|
||||
capture(first.window.launcherStage(),"settings-launcher");
|
||||
}
|
||||
var reopened=new p.studio.core.project.preferences.JsonWindowStateStore(file,mapper);
|
||||
try(var second=harness(catalog,known,setups,reopened,runtimes)){
|
||||
assertEquals(880,fx(()->second.window.launcherStage().getWidth()),3);assertEquals(610,fx(()->second.window.launcherStage().getHeight()),3);
|
||||
open(second,a);assertEquals(1040,fx(second.stage::getWidth),3);assertEquals(730,fx(second.stage::getHeight),3);
|
||||
fire(second.stage,"play");assertTrue(fx(()->second.stage.getScene().lookup("#configure-action").isVisible()),"Disposable choice must reset on project reopening");
|
||||
Thread.sleep(350);fx(()->{second.stage.toFront();second.stage.setMaximized(true);return null;});
|
||||
try{await(()->reopened.load(a).map(WindowGeometry::maximized).orElse(false));}
|
||||
catch(AssertionError failure){fail("maximized="+fx(second.stage::isMaximized)+" geometry="+reopened.load(a),failure);}
|
||||
}
|
||||
try(var third=harness(catalog,known,setups,new p.studio.core.project.preferences.JsonWindowStateStore(file,mapper),runtimes)){
|
||||
open(third,a);await(()->fx(third.stage::isMaximized));Thread.sleep(350);
|
||||
fx(()->{third.stage.setMaximized(false);return null;});
|
||||
try{await(()->fx(()->Math.abs(third.stage.getWidth()-1040)<3&&Math.abs(third.stage.getHeight()-730)<3));}
|
||||
catch(AssertionError failure){fail("restored="+fx(()->third.stage.getWidth()+"x"+third.stage.getHeight()+" maximized="+third.stage.isMaximized())+" saved="+reopened.load(a),failure);}
|
||||
closeProject(third);open(third,b);assertEquals(820,fx(third.stage::getWidth),3);assertEquals(620,fx(third.stage::getHeight),3);
|
||||
fx(()->{third.window.openProjectSettings(false);return null;});Stage config=settings();
|
||||
fx(()->{((CheckBox)config.getScene().lookup("#runtime-inherit")).setSelected(false);((TextField)config.getScene().lookup("#runtime-path")).setText(temporary.resolve("invalid").toString());return null;});
|
||||
fire(config,"settings-apply");await(()->fx(()->!((Label)config.getScene().lookup("#settings-feedback")).getText().isBlank()));
|
||||
assertNull(setups.load(b).prometeuRuntimePath(),"Invalid override must not be saved");fire(config,"settings-cancel");
|
||||
capture(third.stage,"iteration-project");
|
||||
}
|
||||
}
|
||||
|
||||
@Test void completeProjectFlowWindowsAppearanceWizardAndRecovery()throws Exception {
|
||||
var mapper=new ObjectMapper();Path projects=Files.createDirectories(temporary.resolve("projects"));
|
||||
@@ -83,7 +239,12 @@ class StudioProjectsDesktopTest {
|
||||
try {
|
||||
fx(()->{window.showLauncher();return null;});Stage launcher=fx(window::launcherStage);
|
||||
fx(()->{for(String id:List.of("studio-shell","theme-select","language-select","typeface-select","scale-select"))
|
||||
assertNull(launcher.getScene().lookup("#"+id),"Project selection must not contain "+id);return null;});
|
||||
assertNull(launcher.getScene().lookup("#"+id),"Project selection must not contain "+id);
|
||||
var menu=((MenuBar)launcher.getScene().lookup("#studio-menus")).getMenus().getFirst();
|
||||
assertEquals("Prometeu Studio",menu.getText());assertNotNull(menu.getGraphic());
|
||||
var chooser=launcher.getScene().lookup("#project-chooser");
|
||||
assertTrue(chooser.lookupAll(".label").stream().filter(n->n instanceof Label).noneMatch(n->"Prometeu Studio".equals(((Label)n).getText())),"Brand must appear once, in the menu");
|
||||
return null;});
|
||||
await(()->fx(()->!launcher.getScene().lookup("#open-project").isDisabled()));
|
||||
assertFalse(fx(stage::isShowing));capture(launcher,"launcher-dark");
|
||||
double[] before=launcherLayout(launcher);
|
||||
@@ -127,9 +288,13 @@ class StudioProjectsDesktopTest {
|
||||
// Keyboard opening uses the selected project and restores its geometry.
|
||||
fx(()->{Node list=launcher.getScene().lookup("#known-projects");list.fireEvent(new KeyEvent(KeyEvent.KEY_PRESSED,"","",KeyCode.ENTER,false,false,false,false));return null;});
|
||||
await(()->fx(()->window.projectSession()!=null));assertEquals(1040,fx(stage::getWidth),3);assertEquals(730,fx(stage::getHeight),3);
|
||||
fx(()->{((ComboBox<Theme>)stage.getScene().lookup("#theme-select")).setValue(Theme.LIGHT);
|
||||
((ComboBox<StudioLanguage>)stage.getScene().lookup("#language-select")).setValue(StudioLanguage.PORTUGUESE);
|
||||
window.requestCloseProject();return null;});await(()->fx(()->launcher.isShowing()&&!launcher.getScene().lookup("#new-project").isDisabled()));
|
||||
fx(()->{assertNull(stage.getScene().lookup("#runtime-path"));assertNull(stage.getScene().lookup("#theme-select"));
|
||||
assertNotNull(stage.getScene().lookup("#project-tabs"));window.openPreferences();return null;});
|
||||
Stage preferences=settings();
|
||||
fx(()->{((ComboBox<Theme>)preferences.getScene().lookup("#theme-select")).setValue(Theme.LIGHT);
|
||||
((ComboBox<StudioLanguage>)preferences.getScene().lookup("#language-select")).setValue(StudioLanguage.PORTUGUESE);return null;});
|
||||
fire(preferences,"settings-apply");await(()->fx(()->!preferences.isShowing()));
|
||||
fx(()->{window.requestCloseProject();return null;});await(()->fx(()->launcher.isShowing()&&!launcher.getScene().lookup("#new-project").isDisabled()));
|
||||
// A wizard cancellation does not leave a stale wizard owner behind.
|
||||
fire(launcher,"new-project");await(()->fx(()->Window.getWindows().stream().anyMatch(w->w.isShowing()&&w.getScene().lookup("#wizard-name")!=null)));
|
||||
fire(wizard(),"wizard-cancel");fire(launcher,"new-project");
|
||||
@@ -145,7 +310,10 @@ class StudioProjectsDesktopTest {
|
||||
capture(wizard,"wizard-confirm-light-pt");fire(wizard,"wizard-create");
|
||||
await(()->fx(()->window.projectSession()!=null));assertEquals("New Adventure",fx(()->window.projectSession().projectReference().name()));
|
||||
Path created=projects.resolve("new-adventure");assertTrue(Files.isRegularFile(created.resolve("prometeu.json")));assertTrue(Files.isDirectory(created.resolve("src")));
|
||||
fx(()->{((ComboBox<Double>)stage.getScene().lookup("#scale-select")).setValue(1.5);window.requestCloseProject();return null;});
|
||||
fx(()->{window.openPreferences();return null;});Stage scalePreferences=settings();
|
||||
fx(()->{((ComboBox<Double>)scalePreferences.getScene().lookup("#scale-select")).setValue(1.5);return null;});
|
||||
fire(scalePreferences,"settings-apply");await(()->fx(()->!scalePreferences.isShowing()));
|
||||
fx(()->{window.requestCloseProject();return null;});
|
||||
await(()->fx(()->launcher.isShowing()&&!launcher.getScene().lookup("#open-project").isDisabled()));capture(launcher,"launcher-light-pt-150");
|
||||
fx(()->{((ScrollPane)launcher.getScene().lookup("#launcher-scroll")).setVvalue(1);return null;});capture(launcher,"launcher-light-pt-150-actions");
|
||||
failOpen.set(true);fire(launcher,"open-project");
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package p.studio.api.preferences;
|
||||
|
||||
/** Machine-local Studio default, separate from frontend appearance and project overrides. */
|
||||
public interface RuntimeSettingsStore {
|
||||
String load();
|
||||
void save(String installation);
|
||||
/** Validate a nonempty installation without starting a runtime. Implementations perform IO off the UI thread. */
|
||||
default void validate(String installation) { }
|
||||
default String resolve(String projectOverride) {
|
||||
String effective = projectOverride == null || projectOverride.isBlank() ? load() : projectOverride.trim();
|
||||
if (effective == null || effective.isBlank()) throw new IllegalArgumentException("Runtime installation is missing");
|
||||
validate(effective);
|
||||
return effective;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,10 @@ import p.studio.api.project.ProjectReference;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface WindowStateStore {
|
||||
default Optional<WindowGeometry> loadLauncher() { return Optional.empty(); }
|
||||
|
||||
default void saveLauncher(WindowGeometry geometry) { }
|
||||
|
||||
Optional<WindowGeometry> load(ProjectReference projectReference);
|
||||
|
||||
void save(ProjectReference projectReference, WindowGeometry geometry);
|
||||
|
||||
@@ -7,4 +7,10 @@ import java.util.function.Consumer;
|
||||
|
||||
public interface Shipper {
|
||||
OperationHandle<ShipperPrepareResult> prepare(ProjectReference project, Consumer<ShipperLogEntry> logSink);
|
||||
|
||||
/** Freeze the selected execution configuration for interactive build admission without persisting inherited defaults. */
|
||||
default OperationHandle<ShipperPrepareResult> prepare(ProjectReference project,
|
||||
p.studio.api.project.ProjectLocalStudioSetup effectiveSetup, Consumer<ShipperLogEntry> logSink) {
|
||||
return prepare(project,logSink);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,7 @@ import p.studio.api.project.ProjectReference;
|
||||
/** The shipper and managed launch adapters consume the same qualified asset budget contract. */
|
||||
public interface AssetBuildPreflight {
|
||||
AssetBudgets.Snapshot inspect(ProjectReference project);
|
||||
default AssetBudgets.Snapshot inspect(ProjectReference project,p.studio.api.project.ProjectLocalStudioSetup effectiveSetup) {
|
||||
return inspect(project);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ final class InteractiveExecutionController implements ExecutionController {
|
||||
private ExecutionSnapshot start(Attempt a) {
|
||||
try {
|
||||
if(a.stopping)return session.snapshot();
|
||||
a.preparation=access.prepareExecution(project.rootPath(),()->shipper.prepare(project,session::appendShipperLog));
|
||||
a.preparation=access.prepareExecution(project.rootPath(),()->shipper.prepare(project,setup,session::appendShipperLog));
|
||||
if(a.stopping)a.preparation.cancel();
|
||||
ShipperPrepareResult prepared=a.preparation.completion().toCompletableFuture().join();
|
||||
a.preparation.termination().toCompletableFuture().join();
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package p.studio.core.project.preferences;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
|
||||
final class AtomicSettingsFile {
|
||||
private AtomicSettingsFile() { }
|
||||
static void write(Path file, ObjectMapper mapper, Object value) {
|
||||
Path temporary = null;
|
||||
try {
|
||||
Files.createDirectories(file.getParent());
|
||||
temporary = Files.createTempFile(file.getParent(), file.getFileName().toString(), ".tmp");
|
||||
mapper.writerWithDefaultPrettyPrinter().writeValue(temporary.toFile(), value);
|
||||
try { Files.move(temporary, file, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING); }
|
||||
catch (AtomicMoveNotSupportedException ignored) { Files.move(temporary, file, StandardCopyOption.REPLACE_EXISTING); }
|
||||
} catch (IOException failure) { throw new UncheckedIOException(failure); }
|
||||
finally { if (temporary != null) try { Files.deleteIfExists(temporary); } catch (IOException ignored) { } }
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package p.studio.core.project.preferences;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import p.studio.api.preferences.RuntimeSettingsStore;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
|
||||
public final class JsonRuntimeSettingsStore implements RuntimeSettingsStore {
|
||||
private final Path file;
|
||||
private final ObjectMapper mapper;
|
||||
public JsonRuntimeSettingsStore(Path file, ObjectMapper mapper) {
|
||||
this.file = file.toAbsolutePath().normalize(); this.mapper = mapper.copy();
|
||||
}
|
||||
private record Settings(String runtimePath) { }
|
||||
@Override public synchronized String load() {
|
||||
if (!Files.exists(file)) return null;
|
||||
try { var value = mapper.readValue(file.toFile(), Settings.class); return normalize(value.runtimePath()); }
|
||||
catch (IOException failure) { throw new UncheckedIOException(failure); }
|
||||
}
|
||||
@Override public synchronized void save(String installation) {
|
||||
String value = normalize(installation);
|
||||
if (value != null) validate(value);
|
||||
AtomicSettingsFile.write(file, mapper, new Settings(value));
|
||||
}
|
||||
@Override public void validate(String installation) {
|
||||
String value = normalize(installation);
|
||||
if (value == null) throw new IllegalArgumentException("Runtime installation is missing");
|
||||
String name = System.getProperty("os.name").startsWith("Windows") ? "prometeu-runtime.exe" : "prometeu-runtime";
|
||||
Path executable = Path.of(value).resolve(name);
|
||||
if (!Files.isRegularFile(executable) || !Files.isExecutable(executable))
|
||||
throw new IllegalArgumentException("Interactive runtime not found: " + executable);
|
||||
}
|
||||
private static String normalize(String text) { return text == null || text.isBlank() ? null : text.trim(); }
|
||||
}
|
||||
+10
-9
@@ -25,20 +25,21 @@ public final class JsonWindowStateStore implements WindowStateStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<WindowGeometry> load(ProjectReference projectReference) {
|
||||
public synchronized Optional<WindowGeometry> load(ProjectReference projectReference) {
|
||||
return Optional.ofNullable(loadFile().projects().get(projectKey(projectReference)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(ProjectReference projectReference, WindowGeometry geometry) {
|
||||
public synchronized void save(ProjectReference projectReference, WindowGeometry geometry) {
|
||||
final WindowStateFile current = loadFile();
|
||||
current.projects().put(projectKey(projectReference), Objects.requireNonNull(geometry, "geometry"));
|
||||
try {
|
||||
Files.createDirectories(storageFile.getParent());
|
||||
mapper.writerWithDefaultPrettyPrinter().writeValue(storageFile.toFile(), current.normalize());
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException(exception);
|
||||
}
|
||||
AtomicSettingsFile.write(storageFile, mapper, current.normalize());
|
||||
}
|
||||
|
||||
@Override public synchronized Optional<WindowGeometry> loadLauncher() { return Optional.ofNullable(loadFile().launcher()); }
|
||||
@Override public synchronized void saveLauncher(WindowGeometry geometry) {
|
||||
var current = loadFile();
|
||||
AtomicSettingsFile.write(storageFile, mapper, new WindowStateFile(geometry, current.projects()));
|
||||
}
|
||||
|
||||
private WindowStateFile loadFile() {
|
||||
@@ -58,7 +59,7 @@ public final class JsonWindowStateStore implements WindowStateStore {
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
private record WindowStateFile(Object launcher, Map<String, WindowGeometry> projects) {
|
||||
private record WindowStateFile(WindowGeometry launcher, Map<String, WindowGeometry> projects) {
|
||||
private static WindowStateFile empty() {
|
||||
return new WindowStateFile(null, new LinkedHashMap<>());
|
||||
}
|
||||
|
||||
@@ -56,6 +56,16 @@ public final class StudioShipperService implements Shipper, SavedProjectPreparat
|
||||
return access.submitManual(project.rootPath(), operations, "Build and pack " + project.name(), () -> prepareNow(project, sink));
|
||||
}
|
||||
|
||||
@Override public OperationHandle<ShipperPrepareResult> prepare(ProjectReference project,
|
||||
p.studio.api.project.ProjectLocalStudioSetup effectiveSetup,Consumer<ShipperLogEntry> sink) {
|
||||
Objects.requireNonNull(effectiveSetup);Objects.requireNonNull(sink);
|
||||
return access.submitManual(project.rootPath(),operations,"Build and pack "+project.name(),()->{
|
||||
var selection=p.studio.api.automation.BuildSelection.productionBuild();
|
||||
return assetPreflight==null?prepareInto(project,selection,project.rootPath().resolve("build"),sink,effectiveSetup)
|
||||
:prepareProduction(project,selection,sink,effectiveSetup);
|
||||
});
|
||||
}
|
||||
|
||||
@Override public ShipperPrepareResult prepareNow(ProjectReference project, Consumer<ShipperLogEntry> sink) {
|
||||
return prepareNow(project, p.studio.api.automation.BuildSelection.productionBuild(), sink);
|
||||
}
|
||||
@@ -113,6 +123,10 @@ public final class StudioShipperService implements Shipper, SavedProjectPreparat
|
||||
}
|
||||
|
||||
private ShipperPrepareResult prepareProduction(ProjectReference project,p.studio.api.automation.BuildSelection selection,Consumer<ShipperLogEntry> sink) {
|
||||
return prepareProduction(project,selection,sink,null);
|
||||
}
|
||||
private ShipperPrepareResult prepareProduction(ProjectReference project,p.studio.api.automation.BuildSelection selection,Consumer<ShipperLogEntry> sink,
|
||||
p.studio.api.project.ProjectLocalStudioSetup effectiveSetup) {
|
||||
Path stage=null;
|
||||
try {
|
||||
var home=project.rootPath().resolve(".studio/build-staging");admitOutput(project.rootPath(),home);Files.createDirectories(home);
|
||||
@@ -120,7 +134,7 @@ public final class StudioShipperService implements Shipper, SavedProjectPreparat
|
||||
packer.validatePackWorkspace(new ValidatePackWorkspaceRequest(new PackerProjectContext(project.name(),project.rootPath())));
|
||||
packer.initWorkspace(new p.packer.messages.InitWorkspaceRequest(new PackerProjectContext(project.name(),project.rootPath())));
|
||||
var inputs=inputHashes(project.rootPath());stage=Files.createTempDirectory(home,"production-");
|
||||
var result=prepareInto(project,selection,stage,sink);if(!result.success())return result;
|
||||
var result=prepareInto(project,selection,stage,sink,effectiveSetup);if(!result.success())return result;
|
||||
verifyConsumedSources(result.context());checkCancelled();
|
||||
final Path candidate=stage;return packer.withProject(new PackerProjectContext(project.name(),project.rootPath()),()->{
|
||||
if(!inputs.equals(inputHashes(project.rootPath())))throw new IOException("Project assets changed before production publication");
|
||||
@@ -141,6 +155,10 @@ public final class StudioShipperService implements Shipper, SavedProjectPreparat
|
||||
|
||||
private ShipperPrepareResult prepareInto(ProjectReference project, p.studio.api.automation.BuildSelection selection,
|
||||
Path outputRoot, Consumer<ShipperLogEntry> sink) {
|
||||
return prepareInto(project,selection,outputRoot,sink,null);
|
||||
}
|
||||
private ShipperPrepareResult prepareInto(ProjectReference project,p.studio.api.automation.BuildSelection selection,
|
||||
Path outputRoot,Consumer<ShipperLogEntry> sink,p.studio.api.project.ProjectLocalStudioSetup effectiveSetup) {
|
||||
Objects.requireNonNull(project); Objects.requireNonNull(sink);
|
||||
var logs = new ArrayList<ShipperLogEntry>();
|
||||
var issues = new ArrayList<p.studio.api.diagnostic.StudioDiagnostic>();
|
||||
@@ -185,7 +203,7 @@ public final class StudioShipperService implements Shipper, SavedProjectPreparat
|
||||
return finish(ShipperPreparationStatus.FAILED, logs, null, List.of(), issues, stages, inputs, "rejected");
|
||||
}
|
||||
stages.put(current, "passed"); checkCancelled(); current = "pack"; stages.put(current, "running");
|
||||
var capacity=assetPreflight==null?null:assetPreflight.inspect(project);
|
||||
var capacity=assetPreflight==null?null:effectiveSetup==null?assetPreflight.inspect(project):assetPreflight.inspect(project,effectiveSetup);
|
||||
if(capacity!=null) {
|
||||
var expanded=new java.util.LinkedHashMap<String,Object>(inputs);expanded.put("assetCapacity",mapper.convertValue(capacity,java.util.Map.class));inputs=expanded;
|
||||
for(var diagnostic:capacity.diagnostics())issues.add(assetIssue(diagnostic,project));
|
||||
|
||||
+15
@@ -37,6 +37,21 @@ class InteractiveExecutionControllerTest {
|
||||
private RuntimeGateway gateway(Connection connection){return (p,s,l)->connection;}
|
||||
private ProjectReference project(){return new ProjectReference("Game","1","pbs",1,ProjectTarget.Game,root);}
|
||||
|
||||
@Test void buildAndLaunchReceiveTheSameFrozenEffectiveRuntime(){
|
||||
var ops=new ControlledOperations();var state=new DefaultExecutionSession();var connection=new Connection();
|
||||
var effective=new ProjectLocalStudioSetup("global-runtime",null);
|
||||
Shipper preparation=new Shipper(){
|
||||
public OperationHandle<ShipperPrepareResult> prepare(ProjectReference p,java.util.function.Consumer<ShipperLogEntry> logs){throw new AssertionError("Interactive build must receive effective setup");}
|
||||
public OperationHandle<ShipperPrepareResult> prepare(ProjectReference p,ProjectLocalStudioSetup setup,java.util.function.Consumer<ShipperLogEntry> logs){
|
||||
assertSame(effective,setup);return done(new ShipperPrepareResult(ShipperPreparationStatus.SUCCESS,List.of(),root.resolve("manifest.json"),List.of(),List.of()));
|
||||
}
|
||||
};
|
||||
RuntimeGateway runtime=(p,setup,logs)->{assertSame(effective,setup);return connection;};
|
||||
var controller=new InteractiveExecutionController(project(),effective,state,preparation,runtime,ops,new ProjectAccessRegistry(),PlayOptions.PERSISTENT);
|
||||
controller.play();ops.last.finish();assertEquals(ExecutionState.RUNNING,state.snapshot().state());
|
||||
var stop=controller.stopAsync();ops.last.finish();stop.toCompletableFuture().join();
|
||||
}
|
||||
|
||||
@Test void failedConnectionReleasesAuthorityAfterCompletionAndAllowsAnotherAttempt(){
|
||||
var ops=new ControlledOperations();var authority=new DefaultAutomationSession(root,ops);
|
||||
var access=new ProjectAccessRegistry();access.register(root,authority::enterManual,()->true,authority);
|
||||
|
||||
+18
@@ -16,6 +16,24 @@ final class JsonWindowStateStoreTest {
|
||||
@TempDir
|
||||
Path tempDir;
|
||||
|
||||
@Test void launcherAndTwoProjectsSurviveInterleavedWritesAndNewInstances() throws Exception {
|
||||
Path file=tempDir.resolve("windows.json");var mapper=new ObjectMapper();
|
||||
var a=new ProjectReference("A","1","pbs",1,ProjectTarget.Game,tempDir.resolve("A"));
|
||||
var b=new ProjectReference("B","1","pbs",1,ProjectTarget.Game,tempDir.resolve("B"));
|
||||
var ga=new WindowGeometry(-1000,30,900,700,true);
|
||||
var gb=new WindowGeometry(80,90,1000,720,false);
|
||||
var launcher=new WindowGeometry(40,50,960,720,true);
|
||||
var store=new JsonWindowStateStore(file,mapper);
|
||||
var pool=java.util.concurrent.Executors.newFixedThreadPool(3);
|
||||
try {
|
||||
var writes=java.util.List.of(pool.submit(()->store.save(a,ga)),pool.submit(()->store.save(b,gb)),pool.submit(()->store.saveLauncher(launcher)));
|
||||
for(var write:writes)write.get();
|
||||
} finally {pool.shutdown();}
|
||||
var reopened=new JsonWindowStateStore(file,mapper);
|
||||
assertEquals(ga,reopened.load(a).orElseThrow());assertEquals(gb,reopened.load(b).orElseThrow());
|
||||
assertEquals(launcher,reopened.loadLauncher().orElseThrow());
|
||||
}
|
||||
|
||||
@Test
|
||||
void persistsGeometryByNormalizedProjectRoot() {
|
||||
final Path storage = tempDir.resolve("window-state.json");
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package p.studio.core.project.preferences;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import java.nio.file.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class RuntimeSettingsStoreTest {
|
||||
@TempDir Path root;
|
||||
private Path installation(String name) throws Exception {
|
||||
Path path=Files.createDirectories(root.resolve(name));
|
||||
Path executable=Files.writeString(path.resolve(System.getProperty("os.name").startsWith("Windows")?"prometeu-runtime.exe":"prometeu-runtime"),"fixture");
|
||||
assertTrue(executable.toFile().setExecutable(true));return path;
|
||||
}
|
||||
@Test void defaultSurvivesRestartAndExplicitInvalidOverrideNeverFallsBack() throws Exception {
|
||||
Path path=root.resolve("settings.json"),global=installation("global"),specific=installation("specific");
|
||||
var store=new JsonRuntimeSettingsStore(path,new ObjectMapper());
|
||||
assertNull(store.load());assertThrows(IllegalArgumentException.class,()->store.resolve(null));
|
||||
store.save(global.toString());
|
||||
var reopened=new JsonRuntimeSettingsStore(path,new ObjectMapper());
|
||||
assertEquals(global.toString(),reopened.resolve(null));
|
||||
assertEquals(specific.toString(),reopened.resolve(specific.toString()));
|
||||
assertThrows(IllegalArgumentException.class,()->reopened.resolve(root.resolve("missing").toString()));
|
||||
assertEquals(global.toString(),reopened.load());
|
||||
reopened.save(null);assertNull(store.load());
|
||||
}
|
||||
@Test void failedUpdatePreservesPriorDefault() throws Exception {
|
||||
var store=new JsonRuntimeSettingsStore(root.resolve("settings.json"),new ObjectMapper());
|
||||
String path=installation("good").toString();store.save(path);
|
||||
assertThrows(IllegalArgumentException.class,()->store.save(root.resolve("invalid").toString()));
|
||||
assertEquals(path,store.load());
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,21 @@ development gallery** demonstrates components, validation, progress, both fonts
|
||||
configurable text scale. Gallery actions operate on sample text only.
|
||||
|
||||
The product project chooser contains identity, the project list and project
|
||||
commands only. It inherits presentation settings; language, theme, typeface and
|
||||
scale selectors remain in the project window. From the repository root, an
|
||||
unqualified `run` starts the product and skips the foundation demo. Launch the
|
||||
commands and access to **Prometeu Studio > Preferences**. The brand appears only in
|
||||
that menu, without a second identity block in the chooser. It inherits presentation settings;
|
||||
appearance selectors and the default runtime live in that separate dialog.
|
||||
**Project > Settings** contains a nullable runtime override and save media choices.
|
||||
The project shell places global Play/Stop and Pause/Resume controls on the right above a Gameplay
|
||||
tab, alongside the left-aligned Prometeu Studio menu and golden-square mark. A small
|
||||
project header and equally sized contextual footer frame the workspace. The product
|
||||
workspace is plain, with balanced top/bottom margins; the standalone foundation
|
||||
keeps its decorative panel. Native tabs
|
||||
use stepped upper corners, an open flat base and Studio theme colors; Gameplay supplies scale information to the
|
||||
footer and owns automatic/manual image scaling, not execution lifetime. From the repository root, an
|
||||
unqualified `run` starts the product and skips the foundation demo. The gold tab
|
||||
outline encloses the content; Gameplay splits game and logs with a draggable
|
||||
horizontal divider. Automatic scale follows this resize, while manual scale stays
|
||||
fixed. Header/footer remain outside the split. Launch the
|
||||
foundation with the explicit module command above (or from that module directory).
|
||||
|
||||
```sh
|
||||
@@ -61,7 +73,7 @@ Semantic theme colors are in `styles/dark.css` and `styles/light.css`. Component
|
||||
|
||||
`UserSettingsStore` uses the Java Preferences node `p/studio/ui/javafx2` for theme, language, bundled typeface and text scale (75–200%). Startup uses dark, Departure Mono and 100%; a supported system locale chooses pt-BR, otherwise English. Invalid individual values fall back independently with diagnostics.
|
||||
|
||||
Load preferences and font/bundle resources before composing views. `SettingsPersistence` debounces writes on its worker, flushes the last choice asynchronously on close, and shuts the worker down. It never writes from the FX thread. Project-window geometry is restored per project through `WindowStateStore`, with IO off the FX thread. Previous frontend presentation preferences are not migrated.
|
||||
Load preferences and font/bundle resources before composing views. `SettingsPersistence` debounces writes on its worker, flushes the last choice asynchronously on close, and shuts the worker down. It never writes from the FX thread. `WindowStateStore` persists launcher and per-project normal geometry plus maximization. Geometry snapshots are stabilized on FX and written serially off FX, with orderly close awaiting pending writes. Placement considers the matching monitor and recovers onto an available display. Previous frontend presentation preferences are not migrated.
|
||||
|
||||
All interface messages live in UTF-8 `messages_en.properties` and `messages_pt_BR.properties`. Missing translations diagnose and fall back to English; an absent English key displays `[key]`. Bundle parity is checked by unit tests. Dynamic feedback retains its key/arguments and is reformatted on locale changes; user-authored text retains its value.
|
||||
|
||||
|
||||
+14
-4
@@ -7,13 +7,23 @@ import javafx.scene.shape.Polygon;
|
||||
final class PixelGeometry {
|
||||
private PixelGeometry() { }
|
||||
static void apply(Region region) {
|
||||
Polygon outline = new Polygon();
|
||||
region.setShape(outline); region.setScaleShape(false); region.setCenterShape(false); region.setPickOnBounds(true);
|
||||
apply(region,false);
|
||||
}
|
||||
/** Tab edges meet the content surface; only the upper corners step inward. */
|
||||
static void applyTab(Region region) {
|
||||
apply(region,true);
|
||||
}
|
||||
private static void apply(Region region,boolean tab) {
|
||||
region.setScaleShape(false); region.setCenterShape(false); region.setPickOnBounds(true);
|
||||
Runnable update = () -> {
|
||||
double w = region.getWidth(), h = region.getHeight(), s = Math.min(4, Math.min(w,h)/6);
|
||||
outline.getPoints().setAll(2*s,0., w-2*s,0., w-2*s,s, w-s,s, w-s,2*s, w,2*s,
|
||||
if(w<=0||h<=0)return;
|
||||
// Publish a new shape so the Region invalidates its cached outline/bounds after resize.
|
||||
region.setShape(tab?new Polygon(2*s,0., w-2*s,0., w-2*s,s, w-s,s, w-s,2*s,
|
||||
w,2*s, w,h, 0.,h, 0.,2*s, s,2*s, s,s, 2*s,s):
|
||||
new Polygon(2*s,0., w-2*s,0., w-2*s,s, w-s,s, w-s,2*s, w,2*s,
|
||||
w,h-2*s, w-s,h-2*s, w-s,h-s, w-2*s,h-s, w-2*s,h, 2*s,h, 2*s,h-s,
|
||||
s,h-s, s,h-2*s, 0.,h-2*s, 0.,2*s, s,2*s, s,s, 2*s,s);
|
||||
s,h-s, s,h-2*s, 0.,h-2*s, 0.,2*s, s,2*s, s,s, 2*s,s));
|
||||
};
|
||||
region.widthProperty().addListener((o,b,a) -> update.run());
|
||||
region.heightProperty().addListener((o,b,a) -> update.run());
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package p.studio.ui.javafx2.components;
|
||||
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.shape.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/** Native tabs with stepped upper corners and a flat base joined to the content surface. */
|
||||
public final class StudioTabs extends TabPane {
|
||||
private static final Object OUTLINE=new Object();
|
||||
private final Path contentOutline=new Path();
|
||||
public StudioTabs(Tab... tabs){
|
||||
super(tabs);getStyleClass().add("studio-tabs");
|
||||
contentOutline.setId("tab-content-outline");contentOutline.getStyleClass().add("studio-tab-content-outline");
|
||||
contentOutline.setManaged(false);contentOutline.setMouseTransparent(true);contentOutline.setFill(null);
|
||||
contentOutline.setViewOrder(-1);
|
||||
}
|
||||
@Override protected double computeMinHeight(double width){
|
||||
double header=0;var area=lookup(".tab-header-area");
|
||||
if(area instanceof Region region)header=region.prefHeight(width);
|
||||
var selected=getSelectionModel().getSelectedItem();double content=0;
|
||||
if(selected!=null&&selected.getContent() instanceof Region region)
|
||||
content=region.getParent() instanceof Region contentArea?contentArea.minHeight(width):region.minHeight(width);
|
||||
return Math.max(super.computeMinHeight(width),snappedTopInset()+snappedBottomInset()+header+content);
|
||||
}
|
||||
@Override protected void layoutChildren(){
|
||||
super.layoutChildren();
|
||||
for(var node:lookupAll(".tab"))if(node instanceof Region header&&!header.getProperties().containsKey(OUTLINE)){
|
||||
header.getProperties().put(OUTLINE,Boolean.TRUE);PixelGeometry.applyTab(header);
|
||||
}
|
||||
if(!getChildren().contains(contentOutline))getChildren().add(contentOutline);
|
||||
layoutContentOutline();
|
||||
}
|
||||
private void layoutContentOutline(){
|
||||
var selected=getSelectionModel().getSelectedItem();var content=selected==null?null:selected.getContent();
|
||||
var area=content==null?null:content.getParent();
|
||||
if(area==null||!area.isVisible()){contentOutline.setVisible(false);return;}
|
||||
var bounds=sceneToLocal(area.localToScene(area.getLayoutBounds()));
|
||||
if(bounds.getWidth()<=2||bounds.getHeight()<=2){contentOutline.setVisible(false);return;}
|
||||
double left=bounds.getMinX()+1,right=bounds.getMaxX()-1,top=bounds.getMinY()+1,bottom=bounds.getMaxY()-1;
|
||||
var edges=new ArrayList<PathElement>();
|
||||
edges.add(new MoveTo(left,top));edges.add(new LineTo(left,bottom));edges.add(new LineTo(right,bottom));edges.add(new LineTo(right,top));
|
||||
var header=lookup(".tab:selected");
|
||||
if(header==null){edges.add(new LineTo(left,top));}
|
||||
else{
|
||||
var tab=sceneToLocal(header.localToScene(header.getLayoutBounds()));
|
||||
double openingLeft=Math.max(left,Math.min(right,tab.getMinX()+1));
|
||||
double openingRight=Math.max(openingLeft,Math.min(right,tab.getMaxX()-1));
|
||||
double join=Math.min(top,tab.getMaxY()-1);
|
||||
edges.add(new LineTo(openingRight,top));edges.add(new LineTo(openingRight,join));
|
||||
edges.add(new MoveTo(left,top));edges.add(new LineTo(openingLeft,top));edges.add(new LineTo(openingLeft,join));
|
||||
}
|
||||
contentOutline.getElements().setAll(edges);contentOutline.setOpacity(selected.isDisable()?.45:1);contentOutline.setVisible(true);
|
||||
}
|
||||
}
|
||||
+33
-7
@@ -1,6 +1,8 @@
|
||||
package p.studio.ui.javafx2.play;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.beans.property.ReadOnlyDoubleProperty;
|
||||
import javafx.beans.property.ReadOnlyDoubleWrapper;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.image.*;
|
||||
import javafx.scene.input.*;
|
||||
@@ -9,16 +11,20 @@ import p.studio.api.execution.*;
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/** Logical-pixel viewport. Reception never waits for the JavaFX pulse. */
|
||||
/** Adaptable presentation surface. Reception never waits for the JavaFX pulse. */
|
||||
public final class PlaybackViewport extends BorderPane implements AutoCloseable {
|
||||
private final ImageView image=new ImageView();
|
||||
private final StackPane surface=new StackPane(image);
|
||||
private final ScrollPane scroll=new ScrollPane(surface);
|
||||
private final ReadOnlyDoubleWrapper scale=new ReadOnlyDoubleWrapper(0);
|
||||
private final Supplier<ExecutionController> controller;
|
||||
private final Supplier<ExecutionState> state;
|
||||
private final EnumSet<KeyCode> pressed=EnumSet.noneOf(KeyCode.class);
|
||||
private final AnimationTimer timer;
|
||||
private WritableImage writable;
|
||||
private int zoom=1,width=0,height=0,touchX=-1,touchY=-1;
|
||||
private int width=0,height=0,touchX=-1,touchY=-1;
|
||||
private boolean manual;
|
||||
private double requestedScale=1;
|
||||
private boolean touching;
|
||||
private long painted,lastFrame;
|
||||
private final long[] latencies=new long[2048];
|
||||
@@ -27,7 +33,8 @@ public final class PlaybackViewport extends BorderPane implements AutoCloseable
|
||||
this.controller=controller;this.state=state;setId("play-viewport");
|
||||
image.setId("game-image");image.setSmooth(false);image.setPreserveRatio(false);
|
||||
surface.setId("game-surface");surface.setFocusTraversable(true);surface.setStyle("-fx-background-color: #080a0a;");
|
||||
ScrollPane scroll=new ScrollPane(surface);scroll.setFitToWidth(true);scroll.setFitToHeight(true);setCenter(scroll);resizeImage();
|
||||
scroll.setFitToWidth(true);scroll.setFitToHeight(true);scroll.setMinSize(0,0);setCenter(scroll);setMinSize(0,0);
|
||||
scroll.viewportBoundsProperty().addListener((o,a,b)->resizeImage());resizeImage();
|
||||
surface.addEventFilter(KeyEvent.KEY_PRESSED,e->key(e,true));
|
||||
surface.addEventFilter(KeyEvent.KEY_RELEASED,e->key(e,false));
|
||||
surface.focusedProperty().addListener((o,a,b)->{if(!b)neutralize();});
|
||||
@@ -37,9 +44,26 @@ public final class PlaybackViewport extends BorderPane implements AutoCloseable
|
||||
surface.addEventFilter(MouseEvent.MOUSE_RELEASED,e->{if(e.getButton()==MouseButton.PRIMARY)touch(e,false);});
|
||||
timer=new AnimationTimer(){@Override public void handle(long now){paint();}};timer.start();
|
||||
}
|
||||
public void zoom(int value){if(value!=1&&value!=2&&value!=4)throw new IllegalArgumentException("Zoom");zoom=value;resizeImage();}
|
||||
public int zoom(){return zoom;}
|
||||
private void resizeImage(){image.setFitWidth(width*zoom);image.setFitHeight(height*zoom);surface.setMinSize(width*zoom,height*zoom);}
|
||||
public ReadOnlyDoubleProperty scaleProperty(){return scale.getReadOnlyProperty();}
|
||||
public double scale(){return scale.get();}
|
||||
public boolean manual(){return manual;}
|
||||
public void setManual(boolean value){
|
||||
if(value&&!manual)requestedScale=Math.max(.25,Math.min(4,scale.get()>0?scale.get():1));
|
||||
manual=value;resizeImage();
|
||||
}
|
||||
public void setScale(double value){
|
||||
if(!Double.isFinite(value)||value<.25||value>4)throw new IllegalArgumentException("Scale must be between 25% and 400%");
|
||||
requestedScale=value;resizeImage();
|
||||
}
|
||||
private void resizeImage(){
|
||||
scroll.setHbarPolicy(manual?ScrollPane.ScrollBarPolicy.AS_NEEDED:ScrollPane.ScrollBarPolicy.NEVER);
|
||||
scroll.setVbarPolicy(manual?ScrollPane.ScrollBarPolicy.AS_NEEDED:ScrollPane.ScrollBarPolicy.NEVER);
|
||||
double factor=manual?requestedScale:ViewportTransform.fit(width,height,scroll.getViewportBounds().getWidth(),scroll.getViewportBounds().getHeight());
|
||||
if(width<=0||height<=0||factor<=0)return;
|
||||
image.setFitWidth(width*factor);image.setFitHeight(height*factor);
|
||||
surface.setMinSize(manual?width*factor:0,manual?height*factor:0);
|
||||
surface.setPrefSize(manual?width*factor:0,manual?height*factor:0);scale.set(factor);
|
||||
}
|
||||
private void paint(){
|
||||
ExecutionController c=controller.get();if(c==null)return;
|
||||
try(ExecutionFrame frame=c.acquireLatestFrame()){
|
||||
@@ -65,7 +89,9 @@ public final class PlaybackViewport extends BorderPane implements AutoCloseable
|
||||
// After leaving the image, dragging back with the button held cannot recapture.
|
||||
if(down&&!touching&&event.getEventType()!=MouseEvent.MOUSE_PRESSED)return;
|
||||
var p=image.sceneToLocal(event.getSceneX(),event.getSceneY());
|
||||
int x=(int)Math.floor(p.getX()/zoom),y=(int)Math.floor(p.getY()/zoom);
|
||||
var bounds=image.getBoundsInLocal();
|
||||
int x=ViewportTransform.coordinate(p.getX()-bounds.getMinX(),bounds.getWidth(),width);
|
||||
int y=ViewportTransform.coordinate(p.getY()-bounds.getMinY(),bounds.getHeight(),height);
|
||||
touching=down&&state.get()==ExecutionState.RUNNING&&x>=0&&y>=0&&x<width&&y<height;
|
||||
touchX=touching?x:-1;touchY=touching?y:-1;send();event.consume();
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package p.studio.ui.javafx2.play;
|
||||
|
||||
final class ViewportTransform {
|
||||
private ViewportTransform() { }
|
||||
static double fit(int width,int height,double availableWidth,double availableHeight){
|
||||
if(width<=0||height<=0||availableWidth<=0||availableHeight<=0)return 0;
|
||||
return Math.min(availableWidth/width,availableHeight/height);
|
||||
}
|
||||
static int coordinate(double local,double displayed,int nativeSize){
|
||||
if(!Double.isFinite(local)||displayed<=0||nativeSize<=0||local<0||local>=displayed)return -1;
|
||||
return (int)Math.floor(local/displayed*nativeSize);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package p.studio.ui.javafx2.shell;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.text.Text;
|
||||
import p.studio.ui.javafx2.appearance.AppearanceContext;
|
||||
|
||||
/** Keeps navigation on the left and a stable command pair on the right. */
|
||||
public final class ExecutionBar extends Region {
|
||||
private static final double GAP=12;
|
||||
private final MenuBar navigation;
|
||||
private final HBox commands;
|
||||
public ExecutionBar(AppearanceContext context,MenuBar navigation,ButtonBase play,ButtonBase pause){
|
||||
this.navigation=navigation;commands=new HBox(10,play,pause);commands.setAlignment(Pos.CENTER);
|
||||
getChildren().addAll(navigation,commands);getStyleClass().add("studio-execution-bar");setId("execution-toolbar");
|
||||
Runnable measure=()->{
|
||||
double width=0;
|
||||
for(var button:new ButtonBase[]{play,pause})for(String key:new String[]{"play.start","play.stop","play.pause","play.resume"}){
|
||||
var text=new Text(context.text(key));text.setFont(button.getFont());
|
||||
width=Math.max(width,text.getLayoutBounds().getWidth()+button.getPadding().getLeft()+button.getPadding().getRight()+12);
|
||||
}
|
||||
double slot=Math.ceil(width);
|
||||
for(var button:new ButtonBase[]{play,pause}){button.setMinWidth(slot);button.setPrefWidth(slot);button.setMaxWidth(slot);}
|
||||
requestLayout();
|
||||
};
|
||||
ChangeListener<Object> changed=(o,a,b)->measure.run();
|
||||
play.fontProperty().addListener(changed);pause.fontProperty().addListener(changed);
|
||||
play.paddingProperty().addListener(changed);pause.paddingProperty().addListener(changed);
|
||||
context.observe(measure);
|
||||
context.onClose(()->{play.fontProperty().removeListener(changed);pause.fontProperty().removeListener(changed);
|
||||
play.paddingProperty().removeListener(changed);pause.paddingProperty().removeListener(changed);});
|
||||
}
|
||||
private boolean beside(double width){return width>=navigation.prefWidth(-1)+GAP+commands.prefWidth(-1);}
|
||||
@Override public javafx.geometry.Orientation getContentBias(){return javafx.geometry.Orientation.HORIZONTAL;}
|
||||
@Override protected double computeMinWidth(double height){return snappedLeftInset()+snappedRightInset()+Math.max(navigation.minWidth(-1),commands.minWidth(-1));}
|
||||
@Override protected double computePrefWidth(double height){return snappedLeftInset()+snappedRightInset()+navigation.prefWidth(-1)+GAP+commands.prefWidth(-1);}
|
||||
@Override protected double computePrefHeight(double width){
|
||||
double inner=width<0?computePrefWidth(-1):Math.max(0,width-snappedLeftInset()-snappedRightInset());
|
||||
double menu=navigation.prefHeight(inner),buttons=commands.prefHeight(-1);
|
||||
return snappedTopInset()+snappedBottomInset()+(beside(inner)?Math.max(menu,buttons):menu+4+buttons);
|
||||
}
|
||||
@Override protected void layoutChildren(){
|
||||
double x=snappedLeftInset(),y=snappedTopInset(),width=Math.max(0,getWidth()-x-snappedRightInset());
|
||||
double menuWidth=Math.min(width,navigation.prefWidth(-1)),menuHeight=navigation.prefHeight(menuWidth);
|
||||
double commandWidth=commands.prefWidth(-1),commandHeight=commands.prefHeight(commandWidth);
|
||||
boolean oneRow=beside(width);double rowHeight=Math.max(menuHeight,commandHeight);
|
||||
navigation.resizeRelocate(x,y+(oneRow?(rowHeight-menuHeight)/2:0),menuWidth,menuHeight);
|
||||
commands.resizeRelocate(x+width-commandWidth,y+(oneRow?(rowHeight-commandHeight)/2:menuHeight+4),commandWidth,commandHeight);
|
||||
}
|
||||
}
|
||||
+11
-4
@@ -11,11 +11,17 @@ import p.studio.ui.javafx2.i18n.StudioLanguage;
|
||||
|
||||
/** Shared shell: identity, presentation selectors and a workspace supplied by its coordinator. */
|
||||
public final class MinimalShell extends BorderPane {
|
||||
private final StudioPanel workspace = new StudioPanel();
|
||||
private final StackPane workspace;
|
||||
private final StudioSelect<Theme> theme;
|
||||
private final StudioSelect<StudioLanguage> language;
|
||||
public MinimalShell(AppearanceContext context) {
|
||||
this(context,true);
|
||||
}
|
||||
/** Product shell delegates navigation and presentation preferences to its coordinator. */
|
||||
public MinimalShell(AppearanceContext context, boolean foundationSelectors) {
|
||||
workspace=foundationSelectors?new StudioPanel():new StackPane();
|
||||
setId("studio-shell"); getStyleClass().add("studio-shell"); context.attach(this);
|
||||
if(!foundationSelectors){getStyleClass().add("studio-project-shell");setMinSize(0,0);workspace.setMinSize(0,0);}
|
||||
theme = new StudioSelect<>(context,"theme.label",item -> context.text(item.labelKey()),Theme.values());
|
||||
theme.setId("theme-select"); theme.connect(() -> context.settings().theme(), value -> context.update(context.settings().withTheme(value)));
|
||||
language = new StudioSelect<>(context,"language.label",StudioLanguage::label,StudioLanguage.values());
|
||||
@@ -29,15 +35,16 @@ public final class MinimalShell extends BorderPane {
|
||||
labeled(context,"font.label",typeface),labeled(context,"scale.label",scale));
|
||||
selectors.setPrefWrapLength(680);
|
||||
PresentationToolbar toolbar = new PresentationToolbar(identity,selectors);
|
||||
setTop(toolbar); workspace.setId("empty-workspace"); workspace.getStyleClass().add("workspace");
|
||||
if(foundationSelectors)setTop(toolbar);
|
||||
workspace.setId("empty-workspace"); workspace.getStyleClass().add("workspace");
|
||||
context.observe(() -> workspace.setAccessibleText(context.text("workspace.empty")));
|
||||
setMargin(workspace,new Insets(18,18,0,18)); setCenter(workspace);
|
||||
setMargin(workspace,foundationSelectors?new Insets(18,18,0,18):new Insets(18)); setCenter(workspace);
|
||||
}
|
||||
public static VBox labeled(AppearanceContext context, String key, Node input) {
|
||||
Label label = new StudioText(context,key); label.setLabelFor(input);
|
||||
VBox box = new VBox(6,label,input); box.setFillWidth(true); return box;
|
||||
}
|
||||
public StudioPanel workspace() { return workspace; }
|
||||
public StackPane workspace() { return workspace; }
|
||||
public StudioSelect<Theme> themeSelector() { return theme; }
|
||||
public StudioSelect<StudioLanguage> languageSelector() { return language; }
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package p.studio.ui.javafx2.shell;
|
||||
|
||||
import javafx.beans.value.*;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.scene.control.*;
|
||||
import java.util.*;
|
||||
|
||||
/** A small view-owned registration; unregistered tabs never inherit another tab's status. */
|
||||
public final class TabStatusFooter extends Label implements AutoCloseable {
|
||||
private final TabPane tabs;
|
||||
private final Map<Tab,ObservableStringValue> information=new HashMap<>();
|
||||
private final ChangeListener<Tab> selected=(o,a,b)->refresh();
|
||||
private final ListChangeListener<Tab> removed=change->{while(change.next())for(Tab tab:change.getRemoved())information.remove(tab);refresh();};
|
||||
public TabStatusFooter(TabPane tabs){
|
||||
this.tabs=tabs;setId("studio-footer");getStyleClass().addAll("studio-information-strip","studio-footer");
|
||||
setMaxWidth(Double.MAX_VALUE);setWrapText(false);
|
||||
tabs.getSelectionModel().selectedItemProperty().addListener(selected);tabs.getTabs().addListener(removed);
|
||||
var tooltip=new Tooltip();tooltip.textProperty().bind(textProperty());setTooltip(tooltip);
|
||||
}
|
||||
public void information(Tab tab,ObservableStringValue value){information.put(tab,value);refresh();}
|
||||
private void refresh(){
|
||||
textProperty().unbind();var value=information.get(tabs.getSelectionModel().getSelectedItem());
|
||||
if(value==null)setText("");else textProperty().bind(value);
|
||||
}
|
||||
@Override public void close(){
|
||||
textProperty().unbind();tabs.getSelectionModel().selectedItemProperty().removeListener(selected);tabs.getTabs().removeListener(removed);
|
||||
getTooltip().hide();getTooltip().textProperty().unbind();information.clear();
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -52,16 +52,17 @@ final class ProjectChooser extends BorderPane {
|
||||
list.getSelectionModel().selectedItemProperty().addListener((o,a,b)->refresh());
|
||||
list.setOnMouseClicked(event->{if(event.getClickCount()==2)selected.run();});
|
||||
list.setOnKeyPressed(event->{if(event.getCode()==KeyCode.ENTER){selected.run();event.consume();}});
|
||||
FlowPane actions=new FlowPane(12,10,open,add,create,forget,retry);
|
||||
VBox content=new VBox(14,new StudioText(context,"projects.title").title(),list,actions);
|
||||
content.setPadding(new Insets(12));VBox.setVgrow(list,Priority.ALWAYS);
|
||||
HBox identity=new HBox(12,new StudioIcon(),new StudioText(context,"brand").title());
|
||||
identity.setAlignment(javafx.geometry.Pos.CENTER_LEFT);
|
||||
FlowPane actions=new FlowPane(12,12,open,add,create,forget,retry);
|
||||
VBox content=new VBox(18,new StudioText(context,"projects.title").title(),list,actions);
|
||||
VBox.setVgrow(list,Priority.ALWAYS);
|
||||
StudioPanel frame=new StudioPanel(content);frame.setId("projects-frame");
|
||||
VBox layout=new VBox(20,identity,frame);layout.setPadding(new Insets(24));VBox.setVgrow(frame,Priority.ALWAYS);
|
||||
frame.getStyleClass().add("studio-window-panel");
|
||||
VBox layout=new VBox(frame);layout.setPadding(new Insets(18));VBox.setVgrow(frame,Priority.ALWAYS);
|
||||
layout.setMinHeight(Region.USE_PREF_SIZE);
|
||||
ScrollPane page=new ScrollPane(layout);page.setFitToWidth(true);page.setFitToHeight(true);page.setId("launcher-scroll");setCenter(page);
|
||||
message.setId("launcher-notice");message.setWrapText(true);setBottom(message);BorderPane.setMargin(message,new Insets(12,24,12,24));
|
||||
message.setId("launcher-notice");message.setWrapText(true);
|
||||
message.visibleProperty().bind(message.textProperty().isNotEmpty());message.managedProperty().bind(message.visibleProperty());
|
||||
setBottom(message);BorderPane.setMargin(message,new Insets(0,18,18,18));
|
||||
context.observe(()->{if(messageKey!=null)message.setText(context.text(messageKey,messageArguments));});refresh();
|
||||
}
|
||||
private Button action(AppearanceContext context,String key,String id,Runnable action) {
|
||||
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package p.studio.ui.javafx2.window;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.*;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.*;
|
||||
import p.studio.api.preferences.RuntimeSettingsStore;
|
||||
import p.studio.api.project.*;
|
||||
import p.studio.ui.javafx2.appearance.*;
|
||||
import p.studio.ui.javafx2.components.*;
|
||||
import p.studio.ui.javafx2.i18n.StudioLanguage;
|
||||
import p.studio.ui.javafx2.shell.MinimalShell;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.*;
|
||||
|
||||
/** Separate scopes, draft form state and asynchronous Apply. No filesystem orchestration in the UI. */
|
||||
final class SettingsDialogs {
|
||||
record ProjectSettings(ProjectLocalStudioSetup setup, boolean disposable) { }
|
||||
private SettingsDialogs() { }
|
||||
static Stage preferences(Stage owner,WindowResources resources,AppearanceContext parent,String currentRuntime,
|
||||
boolean runtimeLocked,RuntimeSettingsStore store,Executor executor,Consumer<String> applied,Consumer<Boolean> working) {
|
||||
var context=resources.draft(parent);
|
||||
var dialog=new Form(owner,context,"preferences.title",executor,working);
|
||||
var theme=new StudioSelect<Theme>(context,"theme.label",v->context.text(v.labelKey()),Theme.values());
|
||||
theme.setId("theme-select");theme.connect(()->context.settings().theme(),v->context.update(context.settings().withTheme(v)));
|
||||
var language=new StudioSelect<StudioLanguage>(context,"language.label",StudioLanguage::label,StudioLanguage.values());
|
||||
language.setId("language-select");language.connect(()->context.settings().language(),v->context.update(context.settings().withLanguage(v)));
|
||||
var font=new StudioSelect<Typeface>(context,"font.label",Typeface::family,Typeface.values());
|
||||
font.setId("typeface-select");font.connect(()->context.settings().typeface(),v->context.update(context.settings().withTypeface(v)));
|
||||
var scale=new StudioSelect<Double>(context,"scale.label",v->context.text("scale.value",v),.75,1.,1.25,1.5,2.);
|
||||
scale.setId("scale-select");scale.connect(()->context.settings().scale(),v->context.update(context.settings().withScale(v)));
|
||||
var runtime=new StudioTextField();runtime.setId("global-runtime-path");runtime.setText(currentRuntime);
|
||||
var runtimeRow=directory(context,dialog.stage,runtime);runtimeRow.setDisable(runtimeLocked);
|
||||
dialog.fields.getChildren().addAll(new StudioText(context,"preferences.appearance").title(),
|
||||
MinimalShell.labeled(context,"theme.label",theme),MinimalShell.labeled(context,"language.label",language),
|
||||
MinimalShell.labeled(context,"font.label",font),MinimalShell.labeled(context,"scale.label",scale),
|
||||
new Separator(),MinimalShell.labeled(context,"preferences.runtime",runtimeRow));
|
||||
dialog.apply.setOnAction(e->{
|
||||
String path=normalize(runtime.getText());var settings=context.settings();
|
||||
dialog.submit(()->{if(!runtimeLocked)store.save(path);},()->{parent.update(settings);if(!runtimeLocked)applied.accept(path);});
|
||||
});
|
||||
dialog.stage.show();return dialog.stage;
|
||||
}
|
||||
static Stage project(Stage owner,WindowResources resources,AppearanceContext parent,ProjectReference project,
|
||||
ProjectLocalStudioSetup setup,boolean discard,String globalRuntime,RuntimeSettingsStore store,
|
||||
BiConsumer<ProjectReference,ProjectLocalStudioSetup> saver,Executor executor,
|
||||
Consumer<ProjectSettings> applied,Consumer<Boolean> working,boolean savingSection) {
|
||||
var context=resources.child(parent);var dialog=new Form(owner,context,"project.settings.title",executor,working);
|
||||
var inherit=new CheckBox();context.bindText(inherit,"project.runtime.inherit");inherit.setId("runtime-inherit");inherit.setSelected(setup.prometeuRuntimePath()==null);
|
||||
var runtime=new StudioTextField();runtime.setId("runtime-path");runtime.setText(setup.prometeuRuntimePath());
|
||||
var runtimeRow=directory(context,dialog.stage,runtime);runtimeRow.disableProperty().bind(inherit.selectedProperty());
|
||||
var effective=new Label();effective.setWrapText(true);effective.setId("effective-runtime");
|
||||
Runnable update=()->effective.setText(context.text(inherit.isSelected()?"project.runtime.global":"project.runtime.override",
|
||||
inherit.isSelected()?(globalRuntime==null?context.text("settings.unset"):globalRuntime):runtime.getText()));
|
||||
inherit.selectedProperty().addListener((o,a,b)->update.run());runtime.textProperty().addListener((o,a,b)->update.run());context.observe(update);
|
||||
var save=new StudioTextField();save.setId("memcard-path");save.setText(setup.memcardPath());
|
||||
var disposable=new CheckBox();context.bindText(disposable,"play.disposable");disposable.setId("disposable-save");disposable.setSelected(discard);
|
||||
var saveRow=new HBox(12,save,button(context,"play.browse","memcard-browse",()->{
|
||||
var picker=new FileChooser();var file=picker.showOpenDialog(dialog.stage);if(file!=null){save.setText(file.getAbsolutePath());disposable.setSelected(false);}
|
||||
}));HBox.setHgrow(save,Priority.ALWAYS);saveRow.disableProperty().bind(disposable.selectedProperty());
|
||||
dialog.fields.getChildren().addAll(new StudioText(context,"project.execution").title(),inherit,
|
||||
MinimalShell.labeled(context,"play.runtime",runtimeRow),effective);
|
||||
if(project.memcardSlots()!=null)dialog.fields.getChildren().addAll(new Separator(),new StudioText(context,"project.saving").title(),
|
||||
MinimalShell.labeled(context,"play.memcard",saveRow),disposable,new StudioText(context,"project.disposable.temporary"));
|
||||
dialog.apply.setOnAction(e->{
|
||||
var value=new ProjectLocalStudioSetup(inherit.isSelected()?null:normalize(runtime.getText()),setup.editorIndentation(),setup.agentIntegration(),normalize(save.getText()));
|
||||
boolean temporary=project.memcardSlots()!=null&&disposable.isSelected();
|
||||
if(!inherit.isSelected()&&value.prometeuRuntimePath()==null){dialog.feedback.setText(context.text("play.runtime.required"));return;}
|
||||
dialog.submit(()->{if(value.prometeuRuntimePath()!=null)store.validate(value.prometeuRuntimePath());saver.accept(project,value);},
|
||||
()->applied.accept(new ProjectSettings(value,temporary)));
|
||||
});
|
||||
dialog.stage.show();if(savingSection&&project.memcardSlots()!=null)Platform.runLater(()->{dialog.page.setVvalue(1);save.requestFocus();});
|
||||
return dialog.stage;
|
||||
}
|
||||
private static String normalize(String text){return text==null||text.isBlank()?null:text.trim();}
|
||||
private static HBox directory(AppearanceContext context,Stage owner,TextField path){
|
||||
var row=new HBox(12,path,button(context,"play.browse",path.getId()+"-browse",()->{
|
||||
var picker=new DirectoryChooser();var file=picker.showDialog(owner);if(file!=null)path.setText(file.getAbsolutePath());
|
||||
}));HBox.setHgrow(path,Priority.ALWAYS);return row;
|
||||
}
|
||||
private static Button button(AppearanceContext context,String key,String id,Runnable action){
|
||||
var button=new StudioButton(context,key,false);button.setId(id);button.setOnAction(e->action.run());return button;
|
||||
}
|
||||
private static final class Form {
|
||||
final Stage stage=new Stage();final VBox fields=new VBox(12);final Label feedback=new Label();
|
||||
final Button apply;final ScrollPane page=new ScrollPane(fields);
|
||||
private final Executor executor;private final Consumer<Boolean> working;private boolean busy;
|
||||
Form(Stage owner,AppearanceContext context,String title,Executor executor,Consumer<Boolean> working){
|
||||
this.executor=executor;this.working=working;stage.initOwner(owner);stage.initModality(Modality.WINDOW_MODAL);
|
||||
context.observe(()->stage.setTitle(context.text(title)));fields.setPadding(new Insets(20));
|
||||
page.setFitToWidth(true);page.setMinWidth(0);feedback.setWrapText(true);feedback.setId("settings-feedback");
|
||||
apply=button(context,"settings.apply","settings-apply",()->{});apply.setDefaultButton(true);
|
||||
var cancel=button(context,"settings.cancel","settings-cancel",stage::close);cancel.setCancelButton(true);
|
||||
var actions=new HBox(12,cancel,apply);actions.setAlignment(Pos.CENTER_RIGHT);
|
||||
var bottom=new VBox(12,feedback,actions);bottom.setPadding(new Insets(16,20,20,20));
|
||||
var root=new BorderPane(page,null,null,bottom,null);context.attach(root);root.setId("settings-dialog");
|
||||
var screen=Screen.getScreensForRectangle(owner.getX(),owner.getY(),Math.max(1,owner.getWidth()),Math.max(1,owner.getHeight())).stream().findFirst().orElse(Screen.getPrimary()).getVisualBounds();
|
||||
stage.setScene(new Scene(root,Math.min(680,screen.getWidth()*.9),Math.min(660,screen.getHeight()*.85)));
|
||||
stage.setOnCloseRequest(e->{if(busy)e.consume();});stage.setOnHidden(e->context.close());
|
||||
}
|
||||
void submit(Runnable io,Runnable applied){
|
||||
if(busy)return;busy=true;working.accept(true);apply.setDisable(true);fields.setDisable(true);feedback.setText("");
|
||||
try{CompletableFuture.runAsync(io,executor).whenComplete((v,f)->Platform.runLater(()->{
|
||||
busy=false;apply.setDisable(false);fields.setDisable(false);
|
||||
if(f==null){applied.run();stage.close();}else feedback.setText(ProjectOpening.unwrap(f).getMessage());
|
||||
working.accept(false);
|
||||
}));}catch(RuntimeException failure){busy=false;apply.setDisable(false);fields.setDisable(false);feedback.setText(failure.getMessage());working.accept(false);}
|
||||
}
|
||||
}
|
||||
}
|
||||
+202
-76
@@ -3,6 +3,7 @@ package p.studio.ui.javafx2.window;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.animation.PauseTransition;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.util.Duration;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Scene;
|
||||
@@ -17,6 +18,8 @@ import p.studio.ui.javafx2.appearance.AppearanceContext;
|
||||
import p.studio.ui.javafx2.components.*;
|
||||
import p.studio.ui.javafx2.play.PlaybackViewport;
|
||||
import p.studio.ui.javafx2.shell.MinimalShell;
|
||||
import p.studio.ui.javafx2.shell.ExecutionBar;
|
||||
import p.studio.ui.javafx2.shell.TabStatusFooter;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
@@ -29,6 +32,15 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
private Stage loadingStage;
|
||||
private final ProjectLanguageCatalog languages;
|
||||
private final WindowStateStore windows;
|
||||
private final RuntimeSettingsStore runtimeSettings;
|
||||
private String defaultRuntime;
|
||||
private ProjectLocalStudioSetup localSetup;
|
||||
private boolean disposableSave;
|
||||
private final ExecutorService geometryWorker=Executors.newSingleThreadExecutor(r->new Thread(r,"studio-window-state"));
|
||||
private final java.util.concurrent.atomic.AtomicReference<Throwable> geometryFailure=new java.util.concurrent.atomic.AtomicReference<>();
|
||||
private WindowGeometryBinding launcherGeometry,projectGeometry;
|
||||
private boolean launcherLoading;
|
||||
private Stage settingsStage;
|
||||
private final AppearanceContext launcherContext;
|
||||
private AppearanceContext loadingContext;
|
||||
private final ProjectChooser chooser;
|
||||
@@ -53,14 +65,18 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
private AppearanceContext viewContext;
|
||||
private final MinimalShell shell;
|
||||
private final Label notice=new Label();
|
||||
private VBox feedback;
|
||||
private final VBox bottom=new VBox();
|
||||
private final AnimationTimer lifecycle;
|
||||
private ProjectSession project;
|
||||
private ExecutionController controller;
|
||||
private PlaybackViewport viewport;
|
||||
private VBox configuration;
|
||||
private StudioTextField runtimePath,savePath;
|
||||
private CheckBox disposable;
|
||||
private Button play,pause,resume,stop,closeProject;
|
||||
private Button play;
|
||||
private ToggleButton pause;
|
||||
private MenuItem closeProject,projectSettings;
|
||||
private Button configurationAction;
|
||||
private TabPane tabs;
|
||||
private Tab gameplay;
|
||||
private Label stateLabel;
|
||||
private TextArea logs;
|
||||
private long lastLog=-1;
|
||||
@@ -78,19 +94,35 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
public StudioWindowCoordinator2(Stage stage,ProjectCatalog catalog,KnownProjects known,ProjectSessionFactory sessions,
|
||||
ExecutionControllerFactory executions,BiConsumer<ProjectReference,ProjectLocalStudioSetup> saveSetup,
|
||||
Executor executor,WindowResources resources,ProjectLanguageCatalog languages,WindowStateStore windows) {
|
||||
this(stage,catalog,known,sessions,executions,saveSetup,executor,resources,languages,windows,new RuntimeSettingsStore(){
|
||||
private String value; public String load(){return value;} public void save(String path){value=path;}
|
||||
},null);
|
||||
}
|
||||
public StudioWindowCoordinator2(Stage stage,ProjectCatalog catalog,KnownProjects known,ProjectSessionFactory sessions,
|
||||
ExecutionControllerFactory executions,BiConsumer<ProjectReference,ProjectLocalStudioSetup> saveSetup,
|
||||
Executor executor,WindowResources resources,ProjectLanguageCatalog languages,WindowStateStore windows,
|
||||
RuntimeSettingsStore runtimeSettings,String initialRuntime) {
|
||||
this.stage=stage;this.catalog=catalog;this.known=known;this.sessions=sessions;this.executions=executions;
|
||||
this.languages=languages;this.windows=windows;
|
||||
this.runtimeSettings=runtimeSettings;this.defaultRuntime=initialRuntime;
|
||||
this.saveSetup=saveSetup;this.executor=executor;this.resources=resources;
|
||||
context=resources.context();shell=new MinimalShell(context);notice.setWrapText(true);notice.setId("studio-notice");
|
||||
context=resources.context();shell=new MinimalShell(context,false);notice.setWrapText(true);notice.setId("studio-notice");
|
||||
context.observe(()->shell.workspace().setAccessibleText(project==null?context.text("projects.title"):project.projectReference().name()));
|
||||
shell.setBottom(notice);BorderPane.setMargin(notice,new Insets(10,18,12,18));
|
||||
configurationAction=button(context,"settings.open","configure-action",()->{});configurationAction.setVisible(false);configurationAction.setManaged(false);
|
||||
configurationAction.textProperty().unbind();
|
||||
feedback=new VBox(8,notice,configurationAction);feedback.setPadding(new Insets(8,18,12,18));
|
||||
bottom.getChildren().add(feedback);shell.setBottom(bottom);
|
||||
feedback.visibleProperty().bind(notice.textProperty().isNotEmpty().or(configurationAction.visibleProperty()));
|
||||
feedback.managedProperty().bind(feedback.visibleProperty());
|
||||
shell.setTop(menus(context,false));
|
||||
stage.setScene(new Scene(shell,1200,850));stage.setTitle("Prometeu Studio");stage.setMinWidth(680);stage.setMinHeight(480);
|
||||
Platform.setImplicitExit(false);
|
||||
stage.setOnCloseRequest(e->{e.consume();requestCloseProject();});
|
||||
launcherContext=resources.child(context);
|
||||
chooser=new ProjectChooser(launcherContext,p->safe(()->openProject(p)),()->safe(this::addExisting),
|
||||
()->safe(this::newProject),ref->safe(()->forget(ref)),()->openingRetry());
|
||||
launcherStage.setScene(new Scene(chooser,960,720));launcherStage.setMinWidth(600);launcherStage.setMinHeight(440);
|
||||
var launcherRoot=new BorderPane(chooser,menus(launcherContext,false),null,null,null);launcherContext.attach(launcherRoot);
|
||||
launcherStage.setScene(new Scene(launcherRoot,960,720));launcherStage.setMinWidth(600);launcherStage.setMinHeight(440);
|
||||
context.observe(()->{launcherStage.setTitle(context.text("brand"));stage.setTitle(project==null?context.text("brand"):project.projectReference().name()+" · "+context.text("brand"));});
|
||||
launcherStage.setOnCloseRequest(e->{e.consume();exitPlatform=true;exitRequested=true;requestCloseProject();});
|
||||
opening=new ProjectOpening(catalog,known,sessions,windows,executor,Platform::runLater,System::nanoTime,(nanos,action)->{
|
||||
@@ -100,7 +132,7 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
public void resolved(ProjectReference reference){loadingProject.setText(reference.name());}
|
||||
public void prepare(ProjectSession session,WindowGeometry geometry){project=session;showProject();restoreGeometry(geometry);}
|
||||
public void present(){stage.setTitle(project.projectReference().name()+" · "+context.text("brand"));stage.show();stage.toFront();hideLoading();createdProject=null;refresh();}
|
||||
public void discard(){stage.hide();project=null;play=null;if(viewport!=null){viewport.close();viewport=null;}if(viewContext!=null){viewContext.close();viewContext=null;}shell.workspace().getChildren().clear();}
|
||||
public void discard(){if(projectGeometry!=null){projectGeometry.close();projectGeometry=null;}stage.hide();project=null;play=null;if(viewport!=null){viewport.close();viewport=null;}if(viewContext!=null){viewContext.close();viewContext=null;}shell.workspace().getChildren().clear();}
|
||||
public void failed(Throwable failure,boolean cleanupRequired){hideLoading();showChooser();
|
||||
String detail=diagnostic(failure);
|
||||
chooser.feedback(cleanupRequired?"projects.cleanupFailed":createdProject==null?"projects.openFailed":"projects.createdOpenFailed",cleanupRequired,detail);
|
||||
@@ -135,8 +167,20 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
catch(RuntimeException failure){if(!closed)result.accept(null,failure);}
|
||||
}
|
||||
private void showChooser(){
|
||||
stage.hide();launcherStage.show();launcherStage.centerOnScreen();launcherStage.toFront();
|
||||
reloadProjects(null);
|
||||
stage.hide();
|
||||
if(launcherGeometry==null){
|
||||
if(launcherLoading)return;launcherLoading=true;
|
||||
background(()->windows.loadLauncher().orElse(null),(saved,failure)->{
|
||||
launcherLoading=false;if(exitRequested)return;
|
||||
launcherGeometry=new WindowGeometryBinding(launcherStage,saved,960,720,geometryWorker,windows::saveLauncher,this::geometryError);
|
||||
if(project==null&&!opening.busy()){launcherStage.show();launcherStage.toFront();reloadProjects(null);if(failure!=null)error(failure);}
|
||||
});
|
||||
}else {launcherStage.show();launcherStage.toFront();reloadProjects(null);}
|
||||
}
|
||||
private void geometryError(Throwable failure){
|
||||
geometryFailure.set(failure);
|
||||
if(Platform.isFxApplicationThread()){if(!closed)error(failure);}
|
||||
else Platform.runLater(()->{if(!closed)error(failure);});
|
||||
}
|
||||
private void reloadProjects(Path selection){
|
||||
chooser.busy(true);
|
||||
@@ -187,9 +231,12 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
String versionText=System.getProperty("prometeu.studio.version",Optional.ofNullable(getClass().getPackage().getImplementationVersion()).orElse("dev"));
|
||||
Label version=new Label();loadingContext.observe(()->version.setText(context.text("projects.version",versionText)));
|
||||
loadingProject=new Label(path.getFileName()==null?path.toString():path.getFileName().toString());loadingProject.setWrapText(true);
|
||||
VBox body=new VBox(16,new HBox(12,new StudioIcon(),new StudioText(loadingContext,"brand").title()),version,loadingProject,loadingStatus,loadingFeedback);
|
||||
body.setPadding(new Insets(28));StudioPanel frame=new StudioPanel(body);loadingContext.attach(frame);
|
||||
ScrollPane page=new ScrollPane(frame);page.setFitToWidth(true);loadingContext.attach(page);
|
||||
var identity=new HBox(12,new StudioIcon(),new StudioText(loadingContext,"brand").title());identity.setAlignment(javafx.geometry.Pos.CENTER_LEFT);
|
||||
VBox body=new VBox(18,identity,version,loadingProject,loadingStatus,loadingFeedback);
|
||||
body.setAlignment(javafx.geometry.Pos.CENTER_LEFT);
|
||||
StudioPanel frame=new StudioPanel(body);frame.getStyleClass().add("studio-window-panel");loadingContext.attach(frame);
|
||||
VBox layout=new VBox(frame);layout.setPadding(new Insets(18));layout.setMinHeight(Region.USE_PREF_SIZE);VBox.setVgrow(frame,Priority.ALWAYS);
|
||||
ScrollPane page=new ScrollPane(layout);page.setFitToWidth(true);page.setFitToHeight(true);loadingContext.attach(page);
|
||||
double scale=context.settings().scale();var bounds=Screen.getPrimary().getVisualBounds();
|
||||
loadingStage.setScene(new Scene(page,Math.min(bounds.getWidth()*.9,560*scale),Math.min(bounds.getHeight()*.85,340*scale)));loadingStage.setResizable(false);
|
||||
loadingStage.setOnCloseRequest(e->{e.consume();exitPlatform=true;exitRequested=true;requestCloseProject();});
|
||||
@@ -200,74 +247,138 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
private void hideLoading(){if(loadingStage!=null){loadingStage.hide();loadingStage.setOnCloseRequest(null);loadingStage=null;}
|
||||
if(loadingContext!=null){loadingContext.close();loadingContext=null;}loadingStatus=null;loadingProject=null;loadingFeedback=null;}
|
||||
private void restoreGeometry(WindowGeometry geometry){
|
||||
stage.setMaximized(false);stage.setWidth(1200);stage.setHeight(850);
|
||||
if(geometry==null){stage.centerOnScreen();return;}
|
||||
var bounds=Screen.getPrimary().getVisualBounds();
|
||||
double width=Double.isFinite(geometry.width())?Math.max(680,Math.min(geometry.width(),bounds.getWidth())):1200;
|
||||
double height=Double.isFinite(geometry.height())?Math.max(480,Math.min(geometry.height(),bounds.getHeight())):850;
|
||||
stage.setWidth(width);stage.setHeight(height);
|
||||
boolean visible=Screen.getScreens().stream().anyMatch(screen->screen.getVisualBounds().intersects(geometry.x(),geometry.y(),width,height));
|
||||
if(visible&&Double.isFinite(geometry.x())&&Double.isFinite(geometry.y())){stage.setX(geometry.x());stage.setY(geometry.y());}else stage.centerOnScreen();
|
||||
stage.setMaximized(geometry.maximized());
|
||||
if(projectGeometry!=null)projectGeometry.close();
|
||||
var reference=project.projectReference();
|
||||
projectGeometry=new WindowGeometryBinding(stage,geometry,1200,850,geometryWorker,g->windows.save(reference,g),this::geometryError);
|
||||
}
|
||||
private MenuBar menus(AppearanceContext c,boolean withProject){
|
||||
var studio=new Menu();studio.setGraphic(new StudioIcon());var preferences=new MenuItem();preferences.setId("studio-preferences");
|
||||
c.observe(()->{studio.setText(c.text("menu.studio"));preferences.setText(c.text("preferences.title"));});
|
||||
preferences.setOnAction(e->safe(this::openPreferences));studio.getItems().add(preferences);
|
||||
var bar=new MenuBar(studio);bar.setId("studio-menus");bar.getStyleClass().add("studio-navigation");
|
||||
if(withProject){
|
||||
var menu=new Menu();projectSettings=new MenuItem();projectSettings.setId("project-settings");
|
||||
closeProject=new MenuItem();closeProject.setId("close-project");
|
||||
c.observe(()->{menu.setText(c.text("menu.project"));projectSettings.setText(c.text("project.settings.title"));closeProject.setText(c.text("projects.close"));});
|
||||
projectSettings.setOnAction(e->safe(()->openProjectSettings(false)));closeProject.setOnAction(e->requestCloseProject());
|
||||
menu.getItems().addAll(projectSettings,new SeparatorMenuItem(),closeProject);bar.getMenus().add(menu);
|
||||
}
|
||||
return bar;
|
||||
}
|
||||
private void settingsWorking(boolean working){
|
||||
busy=working;refresh();
|
||||
if(!working&&(projectCloseRequested||exitRequested))requestCloseProject();
|
||||
}
|
||||
public void openPreferences(){
|
||||
if(closed||closing||busy)return;if(settingsStage!=null&&settingsStage.isShowing()){settingsStage.toFront();return;}
|
||||
Stage owner=launcherStage.isShowing()?launcherStage:stage;
|
||||
settingsStage=SettingsDialogs.preferences(owner,resources,context,defaultRuntime,
|
||||
controller!=null&&controller.ownsExecution(),runtimeSettings,executor,value->defaultRuntime=value,this::settingsWorking);
|
||||
}
|
||||
public void openProjectSettings(boolean savingSection){
|
||||
if(project==null||closed||closing||busy||controller!=null&&controller.ownsExecution())return;
|
||||
if(settingsStage!=null&&settingsStage.isShowing()){settingsStage.toFront();return;}
|
||||
var owner=project;
|
||||
settingsStage=SettingsDialogs.project(stage,resources,context,project.projectReference(),localSetup,disposableSave,
|
||||
defaultRuntime,runtimeSettings,saveSetup,executor,value->{if(project==owner){localSetup=value.setup();disposableSave=value.disposable();notice.setText("");configurationAction.setVisible(false);configurationAction.setManaged(false);}},
|
||||
this::settingsWorking,savingSection);
|
||||
}
|
||||
private void configurationNeeded(String message,boolean global,boolean savingSection){
|
||||
notice.setText(message);configurationAction.setVisible(true);configurationAction.setManaged(true);
|
||||
configurationAction.setText(context.text(global?"settings.open.preferences":"settings.open.project"));
|
||||
configurationAction.setOnAction(e->safe(()->{if(global)openPreferences();else openProjectSettings(savingSection);}));
|
||||
}
|
||||
|
||||
public void openProject(Path path){
|
||||
if(closed||exitRequested||busy||project!=null||closing||opening.busy())return;
|
||||
if(!path.equals(createdProject))createdProject=null;
|
||||
chooser.message("",false);chooser.busy(true);showLoading(path);opening.start(path);
|
||||
}
|
||||
private void showProject(){
|
||||
var c=beginView();var ref=project.projectReference();var setup=project.projectLocalStudioSetup();
|
||||
shell.workspace().setAccessibleText(ref.name());
|
||||
Label title=new Label(ref.name());title.getStyleClass().add("studio-title");HBox.setHgrow(title,Priority.ALWAYS);
|
||||
closeProject=button(c,"projects.close","close-project",this::requestCloseProject);
|
||||
HBox heading=new HBox(18,title,closeProject);
|
||||
runtimePath=new StudioTextField();runtimePath.setId("runtime-path");runtimePath.setText(setup.prometeuRuntimePath());
|
||||
Button browseRuntime=button(c,"play.browse","runtime-browse",()->{
|
||||
DirectoryChooser chooser=new DirectoryChooser();var chosen=chooser.showDialog(stage);if(chosen!=null)runtimePath.setText(chosen.getAbsolutePath());});
|
||||
HBox runtimeRow=new HBox(12,runtimePath,browseRuntime);HBox.setHgrow(runtimePath,Priority.ALWAYS);
|
||||
configuration=new VBox(8,MinimalShell.labeled(c,"play.runtime",runtimeRow));
|
||||
disposable=new CheckBox();c.bindText(disposable,"play.disposable");disposable.setId("disposable-save");
|
||||
savePath=new StudioTextField();savePath.setId("memcard-path");savePath.setText(setup.memcardPath());
|
||||
if(ref.memcardSlots()!=null){
|
||||
Button browseSave=button(c,"play.browse","memcard-browse",()->{
|
||||
FileChooser chooser=new FileChooser();var chosen=chooser.showOpenDialog(stage);if(chosen!=null){savePath.setText(chosen.getAbsolutePath());disposable.setSelected(false);}});
|
||||
HBox row=new HBox(12,savePath,browseSave);HBox.setHgrow(savePath,Priority.ALWAYS);
|
||||
disposable.selectedProperty().addListener((o,a,b)->row.setDisable(b));
|
||||
configuration.getChildren().addAll(MinimalShell.labeled(c,"play.memcard",row),disposable);
|
||||
}
|
||||
play=button(c,"play.start","play",this::play);
|
||||
pause=button(c,"play.pause","pause",()->{viewport.neutralize();observe(controller.pause().completion());});
|
||||
resume=button(c,"play.resume","resume",()->{observe(controller.resume().completion());viewport.focusGame();});
|
||||
stop=button(c,"play.stop","stop",()->{viewport.neutralize();observe(controller.stopAsync());});
|
||||
StudioSelect<Integer> zoom=new StudioSelect<>(c,"play.zoom",n->"x"+n,1,2,4);zoom.setId("viewport-zoom");zoom.setValue(1);
|
||||
var c=beginView();var ref=project.projectReference();localSetup=project.projectLocalStudioSetup();disposableSave=false;
|
||||
shell.workspace().setAccessibleText(ref.name());notice.setText("");configurationAction.setVisible(false);configurationAction.setManaged(false);
|
||||
play=button(c,"play.start","play",()->{
|
||||
if(controller!=null&&controller.ownsExecution()){viewport.neutralize();observe(controller.stopAsync());}else play();
|
||||
});
|
||||
play.textProperty().unbind();
|
||||
pause=new StudioToggle(c,"play.pause");pause.setId("pause");
|
||||
pause.textProperty().unbind();
|
||||
var playTip=new Tooltip();playTip.textProperty().bind(play.textProperty());play.setTooltip(playTip);
|
||||
var pauseTip=new Tooltip();pauseTip.textProperty().bind(pause.textProperty());pause.setTooltip(pauseTip);
|
||||
c.onClose(()->{playTip.hide();pauseTip.hide();playTip.textProperty().unbind();pauseTip.textProperty().unbind();});
|
||||
pause.setOnAction(e->safe(()->{
|
||||
var state=project.executionSession().snapshot().state();
|
||||
if(state==ExecutionState.RUNNING){viewport.neutralize();observe(controller.pause().completion());}
|
||||
else if(state==ExecutionState.PAUSED){observe(controller.resume().completion());viewport.focusGame();}
|
||||
refresh();
|
||||
}));
|
||||
stateLabel=new Label();stateLabel.setId("execution-state");stateLabel.setWrapText(false);
|
||||
var identity=new Label(ref.name()+" · "+ref.version());identity.setId("project-information");identity.setMaxWidth(Double.MAX_VALUE);
|
||||
HBox.setHgrow(identity,Priority.ALWAYS);HBox.setHgrow(stateLabel,Priority.SOMETIMES);
|
||||
var header=new HBox(16,identity,stateLabel);header.setAlignment(javafx.geometry.Pos.CENTER_LEFT);
|
||||
header.setId("studio-header");header.getStyleClass().addAll("studio-information-strip","studio-header");
|
||||
var identityTip=new Tooltip();identityTip.textProperty().bind(identity.textProperty());identity.setTooltip(identityTip);
|
||||
var stateTip=new Tooltip();stateTip.textProperty().bind(stateLabel.textProperty());stateLabel.setTooltip(stateTip);
|
||||
c.onClose(()->{identityTip.hide();stateTip.hide();identityTip.textProperty().unbind();stateTip.textProperty().unbind();});
|
||||
shell.setTop(new VBox(new ExecutionBar(c,menus(c,true),play,pause),header));
|
||||
viewport=new PlaybackViewport(()->controller,()->project.executionSession().snapshot().state());
|
||||
zoom.setOnAction(e->{if(zoom.getValue()!=null)viewport.zoom(zoom.getValue());});
|
||||
stateLabel=new Label();stateLabel.setId("execution-state");
|
||||
c.observe(()->{displayedState=null;refresh();});
|
||||
FlowPane controls=new FlowPane(12,10,play,pause,resume,stop,zoom,stateLabel);
|
||||
logs=new TextArea();logs.setId("execution-logs");logs.setEditable(false);logs.setPrefRowCount(4);logs.setWrapText(true);
|
||||
VBox top=new VBox(14,heading,configuration,controls);top.setPadding(new Insets(16));
|
||||
BorderPane body=new BorderPane(viewport,top,null,logs,null);body.setId("project-play");
|
||||
shell.workspace().getChildren().setAll(body);lastLog=-1;refresh();
|
||||
var manual=new CheckBox();c.bindText(manual,"play.scale.manual");manual.setId("manual-scale");
|
||||
var slider=new Slider(25,400,100);slider.setId("game-scale");slider.setBlockIncrement(5);slider.setPrefWidth(210);
|
||||
slider.setAccessibleText(c.text("play.scale.manual"));slider.disableProperty().bind(manual.selectedProperty().not());
|
||||
manual.setOnAction(e->{viewport.setManual(manual.isSelected());if(manual.isSelected())slider.setValue(viewport.scale()>0?viewport.scale()*100:100);});
|
||||
slider.valueProperty().addListener((o,a,b)->{if(manual.isSelected())viewport.setScale(b.doubleValue()/100);});
|
||||
var localControls=new FlowPane(12,10,manual,slider);localControls.setPadding(new Insets(10));
|
||||
var game=new BorderPane(viewport,localControls,null,null,null);game.setId("project-play");
|
||||
viewport.setMinHeight(64);
|
||||
logs=new TextArea();logs.setId("execution-logs");logs.setEditable(false);logs.setPrefRowCount(4);logs.setWrapText(true);logs.setMinHeight(64);
|
||||
var split=new SplitPane(game,logs);split.setId("gameplay-split");split.getStyleClass().add("studio-gameplay-split");
|
||||
split.setOrientation(javafx.geometry.Orientation.VERTICAL);split.setDividerPositions(.8);
|
||||
// Apply the initial ratio after the native window has received its actual size.
|
||||
var initialSplit=new AnimationTimer(){@Override public void handle(long now){
|
||||
if(stage.isShowing()&&split.getHeight()>0){split.setDividerPositions(.8);stop();}
|
||||
}};
|
||||
initialSplit.start();c.onClose(initialSplit::stop);
|
||||
gameplay=new Tab(c.text("gameplay.title"),split);gameplay.setId("gameplay-tab");gameplay.setClosable(false);
|
||||
tabs=new StudioTabs(gameplay);tabs.setId("project-tabs");
|
||||
var statusFooter=new TabStatusFooter(tabs);
|
||||
var gameplayInfo=Bindings.createStringBinding(()->viewport.scale()>0?
|
||||
c.text("gameplay.footer",c.text("play.scale.value",viewport.scale()*100,viewport.scale())):c.text("gameplay.footer.waiting"),
|
||||
viewport.scaleProperty(),c.settingsProperty());
|
||||
statusFooter.information(gameplay,gameplayInfo);
|
||||
var stripHeight=Bindings.createDoubleBinding(()->Math.ceil(identity.getFont().getSize()*1.7),identity.fontProperty());
|
||||
for(var strip:new Region[]{header,statusFooter}){
|
||||
strip.minHeightProperty().bind(stripHeight);strip.prefHeightProperty().bind(stripHeight);strip.maxHeightProperty().bind(stripHeight);
|
||||
}
|
||||
c.onClose(()->{statusFooter.close();gameplayInfo.dispose();
|
||||
for(var strip:new Region[]{header,statusFooter}){strip.minHeightProperty().unbind();strip.prefHeightProperty().unbind();strip.maxHeightProperty().unbind();}
|
||||
stripHeight.dispose();});
|
||||
// Keep reusable feedback in the same themed parent across project views.
|
||||
if(bottom.getChildren().size()>1)bottom.getChildren().remove(1);
|
||||
bottom.getChildren().add(statusFooter);
|
||||
c.observe(()->{gameplay.setText(c.text("gameplay.title"));displayedState=null;refresh();});
|
||||
var page=new ScrollPane(tabs);page.setFitToWidth(true);page.setFitToHeight(true);page.setMinSize(0,0);
|
||||
shell.workspace().getChildren().setAll(page);lastLog=-1;refresh();
|
||||
}
|
||||
private void play(){
|
||||
if(busy||closing||controller!=null&&controller.ownsExecution())return;
|
||||
var original=project.projectLocalStudioSetup();var ref=project.projectReference();
|
||||
String runtime=runtimePath.getText();if(runtime==null||runtime.isBlank())throw new IllegalArgumentException(context.text("play.runtime.required"));
|
||||
boolean discard=ref.memcardSlots()!=null&&disposable.isSelected();
|
||||
if(ref.memcardSlots()!=null&&!discard&&(savePath.getText()==null||savePath.getText().isBlank()))
|
||||
throw new IllegalArgumentException(context.text("play.memcard.required"));
|
||||
var setup=new ProjectLocalStudioSetup(runtime,original.editorIndentation(),original.agentIntegration(),savePath.getText());
|
||||
busy=true;refresh();notice.setText("");
|
||||
background(()->{saveSetup.accept(ref,setup);return setup;},(saved,failure)->{
|
||||
busy=false;if(failure!=null){error(failure);if(exitRequested||projectCloseRequested)requestCloseProject();return;}
|
||||
var original=localSetup;var ref=project.projectReference();boolean discard=ref.memcardSlots()!=null&&disposableSave;
|
||||
if(ref.memcardSlots()!=null&&!discard&&(original.memcardPath()==null||original.memcardPath().isBlank())){
|
||||
configurationNeeded(context.text("play.memcard.required"),false,true);return;
|
||||
}
|
||||
busy=true;refresh();notice.setText("");configurationAction.setVisible(false);configurationAction.setManaged(false);
|
||||
background(()->new ProjectLocalStudioSetup(runtimeSettings.resolve(original.prometeuRuntimePath()),original.editorIndentation(),
|
||||
original.agentIntegration(),original.memcardPath()),(effective,failure)->{
|
||||
busy=false;
|
||||
if(failure!=null){configurationNeeded(context.text("feedback.error",diagnostic(failure)),original.prometeuRuntimePath()==null,false);
|
||||
refresh();if(exitRequested||projectCloseRequested)requestCloseProject();return;}
|
||||
if(closing||exitRequested||projectCloseRequested){requestCloseProject();return;}
|
||||
safe(()->{if(controller!=null)controller.close();
|
||||
controller=executions.create(ref,saved,project.executionSession(),new PlayOptions(discard));
|
||||
observe(controller.play().completion());viewport.focusGame();
|
||||
controller=executions.create(ref,effective,project.executionSession(),new PlayOptions(discard));
|
||||
tabs.getSelectionModel().select(gameplay);observe(controller.play().completion());viewport.focusGame();
|
||||
if(stage.isIconified()||!Window.getWindows().stream().anyMatch(w->w.isFocused()&&belongsToStudio(w)))pauseForFocus();refresh();});
|
||||
});
|
||||
}
|
||||
|
||||
private void observe(CompletionStage<?> operation){
|
||||
ProjectSession originProject=project;ExecutionController originController=controller;
|
||||
long command=++operationSequence;
|
||||
@@ -288,11 +399,16 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
private void refresh(){
|
||||
if(project==null||play==null||closed)return;
|
||||
var snapshot=project.executionSession().snapshot();var state=snapshot.state();boolean owned=controller!=null&&controller.ownsExecution();
|
||||
configuration.setDisable(busy||closing||owned);configuration.setVisible(!owned);configuration.setManaged(!owned);
|
||||
play.setDisable(busy||closing||owned);
|
||||
pause.setDisable(closing||state!=ExecutionState.RUNNING);resume.setDisable(closing||state!=ExecutionState.PAUSED);
|
||||
stop.setDisable(closing||!owned||state==ExecutionState.STOPPING);closeProject.setDisable(closing);
|
||||
if(displayedState!=state){displayedState=state;stateLabel.setText(viewContext.text("state."+state.name()));
|
||||
play.setText(context.text(owned?"play.stop":"play.start"));play.setAccessibleText(play.getText());
|
||||
play.setDisable(busy||closing||state==ExecutionState.STOPPING);
|
||||
pause.setDisable(busy||closing||state!=ExecutionState.RUNNING&&state!=ExecutionState.PAUSED);
|
||||
pause.setSelected(state==ExecutionState.PAUSED||state==ExecutionState.PAUSING);
|
||||
pause.setText(context.text(state==ExecutionState.PAUSED?"play.resume":"play.pause"));pause.setAccessibleText(pause.getText());
|
||||
if(closeProject!=null)closeProject.setDisable(closing||busy);
|
||||
if(projectSettings!=null)projectSettings.setDisable(closing||busy||owned);
|
||||
if(displayedState!=state){displayedState=state;
|
||||
stateLabel.setText(viewContext.text("state."+state.name())+(owned&&disposableSave?" · "+context.text("play.disposable.short"):""));
|
||||
play.getTooltip().hide();pause.getTooltip().hide();
|
||||
if(state!=ExecutionState.RUNNING&&viewport!=null)viewport.neutralize();}
|
||||
long sequence=snapshot.logs().isEmpty()?0:snapshot.logs().getLast().sequence();
|
||||
if(logs!=null&&lastLog!=sequence){lastLog=sequence;StringBuilder text=new StringBuilder();
|
||||
@@ -300,6 +416,7 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
for(var entry:snapshot.logs().subList(start,snapshot.logs().size()))text.append(entry.severity()).append(" · ").append(entry.message()).append('\n');
|
||||
logs.setText(text.toString());logs.positionCaret(logs.getLength());}
|
||||
}
|
||||
|
||||
public void requestCloseProject(){
|
||||
if(closed||closing)return;
|
||||
projectCloseRequested=true;
|
||||
@@ -313,6 +430,7 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
}
|
||||
if(busy){if(exitRequested)notice.setText(context.text("feedback.busy"));return;}
|
||||
if(project==null){projectCloseRequested=false;if(exitRequested)finishExit();return;}
|
||||
if(settingsStage!=null&&settingsStage.isShowing())settingsStage.close();
|
||||
closing=true;refresh();if(viewport!=null)viewport.neutralize();
|
||||
CompletionStage<Void> stopping;
|
||||
try{stopping=controller==null?CompletableFuture.completedFuture(null):controller.stopAsync();}
|
||||
@@ -320,8 +438,8 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
stopping.whenComplete((v,f)->Platform.runLater(()->{
|
||||
if(f!=null){closing=false;exitRequested=false;projectCloseRequested=false;error(f);refresh();return;}
|
||||
var oldProject=project;var oldController=controller;
|
||||
var geometry=new WindowGeometry(stage.getX(),stage.getY(),stage.getWidth(),stage.getHeight(),stage.isMaximized());
|
||||
background(()->closeOwned(oldProject,oldController,geometry),(warning,failure)->{
|
||||
if(projectGeometry!=null){projectGeometry.close();projectGeometry=null;}
|
||||
background(()->closeOwned(oldProject,oldController),(warning,failure)->{
|
||||
if(failure!=null){closing=false;exitRequested=false;projectCloseRequested=false;error(failure);refresh();return;}
|
||||
project=null;controller=null;closing=false;projectCloseRequested=false;play=null;notice.setText("");
|
||||
if(viewport!=null){viewport.close();viewport=null;}if(viewContext!=null){viewContext.close();viewContext=null;}shell.workspace().getChildren().clear();
|
||||
@@ -329,20 +447,28 @@ public final class StudioWindowCoordinator2 implements AutoCloseable {
|
||||
});
|
||||
}));
|
||||
}
|
||||
private Throwable closeOwned(ProjectSession session,ExecutionController execution,WindowGeometry geometry){
|
||||
private Throwable closeOwned(ProjectSession session,ExecutionController execution){
|
||||
RuntimeException warning=null,failure=null;
|
||||
try{windows.save(session.projectReference(),geometry);}catch(RuntimeException error){warning=error;}
|
||||
try{if(execution!=null)execution.close();}catch(RuntimeException error){failure=error;}
|
||||
try{session.close();}catch(RuntimeException error){if(failure==null)failure=error;else failure.addSuppressed(error);}
|
||||
if(failure!=null){if(warning!=null)failure.addSuppressed(warning);throw failure;}return warning;
|
||||
}
|
||||
private void finishExit(){
|
||||
if(closed)return;closed=true;lifecycle.stop();hideLoading();stage.hide();launcherStage.hide();
|
||||
if(closed)return;
|
||||
if(projectGeometry!=null){projectGeometry.close();projectGeometry=null;}
|
||||
if(launcherGeometry!=null){launcherGeometry.close();launcherGeometry=null;}
|
||||
if(settingsStage!=null&&settingsStage.isShowing())settingsStage.close();
|
||||
closed=true;lifecycle.stop();hideLoading();stage.hide();launcherStage.hide();
|
||||
if(viewport!=null){viewport.close();viewport=null;}
|
||||
if(viewContext!=null)viewContext.close();launcherContext.close();context.close();
|
||||
stage.setOnCloseRequest(null);launcherStage.setOnCloseRequest(null);
|
||||
// Preference persistence may flush pending IO; keep it off the FX thread too.
|
||||
try{CompletableFuture.runAsync(resources::close,executor).whenComplete((v,f)->Platform.runLater(()->{
|
||||
try{CompletableFuture.runAsync(()->{
|
||||
geometryWorker.shutdown();
|
||||
try{if(!geometryWorker.awaitTermination(10,TimeUnit.SECONDS))throw new IllegalStateException("Window state did not finish saving");}
|
||||
catch(InterruptedException failure){Thread.currentThread().interrupt();throw new CompletionException(failure);}
|
||||
resources.close();if(geometryFailure.get()!=null)throw new CompletionException(geometryFailure.get());
|
||||
},executor).whenComplete((v,f)->Platform.runLater(()->{
|
||||
if(f==null)shutdown.complete(null);else shutdown.completeExceptionally(f);
|
||||
if(exitPlatform)Platform.exit();
|
||||
}));}catch(RuntimeException failure){shutdown.completeExceptionally(failure);if(exitPlatform)Platform.exit();}
|
||||
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package p.studio.ui.javafx2.window;
|
||||
|
||||
import javafx.animation.PauseTransition;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.stage.*;
|
||||
import javafx.util.Duration;
|
||||
import p.studio.api.preferences.WindowGeometry;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/** FX snapshot and worker persistence. Width/height always describe the normal window. */
|
||||
final class WindowGeometryBinding implements AutoCloseable {
|
||||
private final Stage stage;
|
||||
private final Executor worker;
|
||||
private final Consumer<WindowGeometry> save;
|
||||
private final Consumer<Throwable> failure;
|
||||
private final PauseTransition settle = new PauseTransition(Duration.millis(220));
|
||||
private final PauseTransition activation = new PauseTransition(Duration.millis(250));
|
||||
private WindowGeometry normal;
|
||||
private boolean restoring, closed, restoreNormal;
|
||||
private javafx.event.EventHandler<WindowEvent> shown;
|
||||
private final ChangeListener<Number> geometryListener = (o,a,b) -> changed();
|
||||
private final ChangeListener<Boolean> maximizeListener = (o,a,b) -> {
|
||||
if(!restoring)restoreNormal=!b;
|
||||
changed();
|
||||
};
|
||||
WindowGeometryBinding(Stage stage, WindowGeometry saved, double defaultWidth,double defaultHeight,
|
||||
Executor worker,Consumer<WindowGeometry> save,Consumer<Throwable> failure) {
|
||||
this.stage=stage;this.worker=worker;this.save=save;this.failure=failure;
|
||||
normal=WindowPlacement.fit(saved,Screen.getScreens().stream().map(Screen::getVisualBounds).toList(),
|
||||
stage.getMinWidth(),stage.getMinHeight(),defaultWidth,defaultHeight);
|
||||
restoring=true;stage.setMaximized(false);
|
||||
var screen=Screen.getScreens().stream().filter(s->s.getVisualBounds().contains(normal.x(),normal.y())).findFirst().orElse(Screen.getPrimary());
|
||||
stage.setMinWidth(Math.min(stage.getMinWidth(),screen.getVisualBounds().getWidth()));
|
||||
stage.setMinHeight(Math.min(stage.getMinHeight(),screen.getVisualBounds().getHeight()));
|
||||
applyNormal();stage.setMaximized(normal.maximized());
|
||||
stage.xProperty().addListener(geometryListener);stage.yProperty().addListener(geometryListener);
|
||||
stage.widthProperty().addListener(geometryListener);stage.heightProperty().addListener(geometryListener);
|
||||
stage.maximizedProperty().addListener(maximizeListener);
|
||||
settle.setOnFinished(e -> {
|
||||
if(restoreNormal&&!stage.isMaximized()){
|
||||
restoring=true;applyNormal();restoring=false;restoreNormal=false;
|
||||
}
|
||||
snapshot();
|
||||
});
|
||||
// Native show/geometry notifications can briefly report an unmaximized window.
|
||||
// Do not treat those acknowledgements as a user request to restore normal bounds.
|
||||
activation.setOnFinished(e->{if(!closed){restoring=false;snapshot();}});
|
||||
if(stage.isShowing())activation.play();
|
||||
else {shown=new javafx.event.EventHandler<WindowEvent>(){
|
||||
@Override public void handle(WindowEvent event){
|
||||
stage.removeEventHandler(WindowEvent.WINDOW_SHOWN,this);
|
||||
if(normal.maximized())stage.setMaximized(true);
|
||||
activation.play();
|
||||
}
|
||||
};stage.addEventHandler(WindowEvent.WINDOW_SHOWN,shown);}
|
||||
}
|
||||
private void applyNormal() {
|
||||
stage.setX(normal.x());stage.setY(normal.y());stage.setWidth(normal.width());stage.setHeight(normal.height());
|
||||
}
|
||||
private void changed() { if (!closed && !restoring && stage.isShowing()) settle.playFromStart(); }
|
||||
private void snapshot() {
|
||||
if (restoring || !stage.isShowing() || stage.isIconified()) return;
|
||||
if (!stage.isMaximized()) normal=new WindowGeometry(stage.getX(),stage.getY(),stage.getWidth(),stage.getHeight(),false);
|
||||
var value=new WindowGeometry(normal.x(),normal.y(),normal.width(),normal.height(),stage.isMaximized());
|
||||
try { worker.execute(() -> { try { save.accept(value); } catch (RuntimeException error) { failure.accept(error); } }); }
|
||||
catch (RuntimeException error) { failure.accept(error); }
|
||||
}
|
||||
void flush() {
|
||||
settle.stop();
|
||||
if(restoreNormal&&!stage.isMaximized()){
|
||||
restoring=true;applyNormal();restoring=false;restoreNormal=false;
|
||||
}
|
||||
if(restoring&&normal.maximized()){
|
||||
var value=normal;
|
||||
try{worker.execute(()->{try{save.accept(value);}catch(RuntimeException error){failure.accept(error);}});}
|
||||
catch(RuntimeException error){failure.accept(error);}
|
||||
}else {restoring=false;snapshot();}
|
||||
}
|
||||
@Override public void close() {
|
||||
if (closed) return;flush();closed=true;activation.stop();
|
||||
if(shown!=null)stage.removeEventHandler(WindowEvent.WINDOW_SHOWN,shown);
|
||||
stage.xProperty().removeListener(geometryListener);stage.yProperty().removeListener(geometryListener);
|
||||
stage.widthProperty().removeListener(geometryListener);stage.heightProperty().removeListener(geometryListener);
|
||||
stage.maximizedProperty().removeListener(maximizeListener);
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package p.studio.ui.javafx2.window;
|
||||
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import p.studio.api.preferences.WindowGeometry;
|
||||
import java.util.*;
|
||||
|
||||
/** Pure placement calculation; negative coordinates on an attached display are valid. */
|
||||
final class WindowPlacement {
|
||||
private WindowPlacement() { }
|
||||
static WindowGeometry fit(WindowGeometry saved, List<Rectangle2D> screens, double minWidth, double minHeight,
|
||||
double defaultWidth, double defaultHeight) {
|
||||
Rectangle2D bounds = screens.getFirst();
|
||||
if (saved != null && Double.isFinite(saved.x()) && Double.isFinite(saved.y())) {
|
||||
double best = 0;
|
||||
for (var screen : screens) {
|
||||
double area = Math.max(0, Math.min(saved.x()+positive(saved.width(),defaultWidth),screen.getMaxX())-Math.max(saved.x(),screen.getMinX()))
|
||||
* Math.max(0,Math.min(saved.y()+positive(saved.height(),defaultHeight),screen.getMaxY())-Math.max(saved.y(),screen.getMinY()));
|
||||
if (area > best) { best = area; bounds = screen; }
|
||||
}
|
||||
}
|
||||
double width = Math.min(bounds.getWidth(),Math.max(minWidth,saved == null ? defaultWidth : positive(saved.width(),defaultWidth)));
|
||||
double height = Math.min(bounds.getHeight(),Math.max(minHeight,saved == null ? defaultHeight : positive(saved.height(),defaultHeight)));
|
||||
double x = saved == null || !Double.isFinite(saved.x()) ? bounds.getMinX()+(bounds.getWidth()-width)/2 : saved.x();
|
||||
double y = saved == null || !Double.isFinite(saved.y()) ? bounds.getMinY()+(bounds.getHeight()-height)/2 : saved.y();
|
||||
return new WindowGeometry(Math.max(bounds.getMinX(),Math.min(x,bounds.getMaxX()-width)),
|
||||
Math.max(bounds.getMinY(),Math.min(y,bounds.getMaxY()-height)),width,height,saved != null && saved.maximized());
|
||||
}
|
||||
private static double positive(double value,double fallback) { return Double.isFinite(value) && value > 0 ? value : fallback; }
|
||||
}
|
||||
+1
@@ -23,6 +23,7 @@ public final class WindowResources implements AutoCloseable {
|
||||
fonts=FontResources.load(System.err::println);messages=Messages.load(System.err::println);
|
||||
}
|
||||
public AppearanceContext context(){return new AppearanceContext(initial,messages,fonts,persistence::changed);}
|
||||
public AppearanceContext draft(AppearanceContext parent){return new AppearanceContext(parent.settings(),messages,fonts,value -> { });}
|
||||
public AppearanceContext child(AppearanceContext parent){
|
||||
var child=new AppearanceContext(parent.settings(),messages,fonts,parent::update);
|
||||
javafx.beans.value.ChangeListener<PresentationSettings> listener=(o,a,b)->child.update(b);
|
||||
|
||||
+28
@@ -97,3 +97,31 @@ fonts.title=TEXT COMPARISON
|
||||
fonts.input=Text to compare
|
||||
fonts.sample=Creation starts with an idea. Organize your scenes, adjust the characters and bring the adventure to life. Action, music and imagination: you choose the next step.
|
||||
fonts.licenses=Departure Mono and Roboto Mono · SIL Open Font License 1.1 · Full notices are bundled in the fonts resource directory.
|
||||
|
||||
menu.studio=Prometeu Studio
|
||||
menu.project=Project
|
||||
preferences.title=Studio preferences…
|
||||
preferences.appearance=Appearance
|
||||
preferences.runtime=Default runtime installation
|
||||
project.settings.title=Project settings…
|
||||
project.execution=Execution
|
||||
project.saving=Saving
|
||||
project.runtime.inherit=Use Studio default runtime
|
||||
project.runtime.global=Studio default: {0}
|
||||
project.runtime.override=Project override: {0}
|
||||
project.disposable.temporary=Disposable mode applies only while this project is open.
|
||||
settings.unset=Not configured
|
||||
settings.apply=Apply
|
||||
settings.cancel=Cancel
|
||||
settings.open=Open settings
|
||||
settings.open.preferences=Open Studio preferences
|
||||
settings.open.project=Open project settings
|
||||
gameplay.title=Gameplay
|
||||
play.disposable.short=Disposable save
|
||||
play.scale.manual=Manual scale
|
||||
|
||||
play.scale.value={0,number,0.#}% · {1,number,0.##}×
|
||||
play.scale.waiting=Waiting for image
|
||||
|
||||
gameplay.footer=Gameplay · {0}
|
||||
gameplay.footer.waiting=Gameplay · Waiting for image
|
||||
|
||||
+28
@@ -97,3 +97,31 @@ fonts.title=COMPARAÇÃO DE TEXTO
|
||||
fonts.input=Texto para comparar
|
||||
fonts.sample=A criação começa com uma ideia. Organize suas cenas, ajuste os personagens e dê vida à aventura. Ação, música e imaginação: você escolhe o próximo passo.
|
||||
fonts.licenses=Departure Mono e Roboto Mono · SIL Open Font License 1.1 · Avisos completos incluídos no diretório de recursos de fontes.
|
||||
|
||||
menu.studio=Prometeu Studio
|
||||
menu.project=Projeto
|
||||
preferences.title=Preferências do Studio…
|
||||
preferences.appearance=Aparência
|
||||
preferences.runtime=Instalação padrão do runtime
|
||||
project.settings.title=Configurações do projeto…
|
||||
project.execution=Execução
|
||||
project.saving=Salvamento
|
||||
project.runtime.inherit=Usar runtime padrão do Studio
|
||||
project.runtime.global=Padrão do Studio: {0}
|
||||
project.runtime.override=Específico do projeto: {0}
|
||||
project.disposable.temporary=O modo descartável vale somente enquanto este projeto estiver aberto.
|
||||
settings.unset=Não configurado
|
||||
settings.apply=Aplicar
|
||||
settings.cancel=Cancelar
|
||||
settings.open=Abrir configurações
|
||||
settings.open.preferences=Abrir preferências do Studio
|
||||
settings.open.project=Abrir configurações do projeto
|
||||
gameplay.title=Gameplay
|
||||
play.disposable.short=Save descartável
|
||||
play.scale.manual=Escala manual
|
||||
|
||||
play.scale.value={0,number,0.#}% · {1,number,0.##}×
|
||||
play.scale.waiting=Aguardando imagem
|
||||
|
||||
gameplay.footer=Gameplay · {0}
|
||||
gameplay.footer.waiting=Gameplay · Aguardando imagem
|
||||
|
||||
+40
-1
@@ -23,6 +23,7 @@
|
||||
-fx-background-color: -studio-border, -studio-highlight, -studio-shadow, -studio-workspace;
|
||||
-fx-background-insets: 0, 3, 3 6 6 3, 6;
|
||||
}
|
||||
.studio-window-panel { -fx-padding: 18; }
|
||||
.studio-shell { -fx-padding: 0 0 18 0; }
|
||||
.studio-shell > .workspace { -fx-border-insets: 18; }
|
||||
.studio-button, .studio-toggle {
|
||||
@@ -41,7 +42,7 @@
|
||||
.studio-button.primary:hover { -fx-background-color: -studio-border, -studio-on-accent, derive(-studio-accent, 40%), derive(-studio-accent, 8%); }
|
||||
.studio-button:armed, .studio-toggle:armed { -fx-background-insets: 0, 3, 6 3 3 6, 6; }
|
||||
.studio-button:disabled, .studio-toggle:disabled { -fx-opacity: .45; -fx-cursor: default; }
|
||||
.studio-button:focused, .studio-toggle:focused { -fx-border-color: -studio-focus; -fx-border-width: 2; -fx-border-insets: -4; }
|
||||
.studio-button:focused, .studio-toggle:focused { -fx-border-color: -studio-focus; -fx-border-width: 2; -fx-border-insets: 1; }
|
||||
.studio-field, .studio-select {
|
||||
-fx-background-color: -studio-border, -studio-shadow, -studio-field;
|
||||
-fx-background-insets: 0, 3, 5;
|
||||
@@ -76,3 +77,41 @@
|
||||
.studio-root .scroll-pane, .studio-root .scroll-pane > .viewport { -fx-background-color: -studio-background; }
|
||||
.studio-root .scroll-bar { -fx-background-color: -studio-background; }
|
||||
.studio-root .scroll-bar .thumb { -fx-background-color: -studio-border; -fx-background-radius: 0; }
|
||||
|
||||
.studio-project-shell { -fx-padding: 0; }
|
||||
.studio-execution-bar { -fx-padding: 6 12; -fx-background-color: -studio-surface; }
|
||||
.studio-navigation { -fx-background-color: -studio-surface; -fx-padding: 0; }
|
||||
.studio-navigation .menu { -fx-padding: .45em .65em; }
|
||||
.studio-navigation .menu .label { -fx-text-fill: -studio-text; }
|
||||
.studio-navigation .menu:hover, .studio-navigation .menu:showing { -fx-background-color: -studio-field; }
|
||||
.studio-information-strip { -fx-background-color: -studio-surface; -fx-padding: 4 14; }
|
||||
.studio-header { -fx-border-color: -studio-border; -fx-border-width: 1 0 1 0; }
|
||||
.studio-footer { -fx-border-color: -studio-border; -fx-border-width: 1 0 0 0; -fx-text-fill: -studio-muted; }
|
||||
.studio-tabs > .tab-header-area { -fx-padding: 0; }
|
||||
.studio-tabs > .tab-header-area > .tab-header-background { -fx-background-color: -studio-surface; }
|
||||
.studio-tabs > .tab-content-area { -fx-background-color: -studio-workspace; -fx-padding: 2; }
|
||||
.studio-tab-content-outline { -fx-fill: transparent; -fx-stroke: -studio-accent; -fx-stroke-width: 2; }
|
||||
.studio-gameplay-split { -fx-background-color: transparent; -fx-padding: 0; }
|
||||
.studio-gameplay-split:vertical > .split-pane-divider {
|
||||
/* The native skin uses preferred width as divider thickness in both orientations. */
|
||||
-fx-background-color: -studio-border; -fx-padding: 0 4;
|
||||
-fx-pref-width: 8; -fx-cursor: v-resize;
|
||||
}
|
||||
.studio-gameplay-split > .split-pane-divider:hover { -fx-background-color: -studio-accent; }
|
||||
.studio-gameplay-split > .split-pane-divider > .vertical-grabber { -fx-background-color: -studio-highlight; -fx-padding: 1 14; }
|
||||
.studio-tabs > .tab-header-area > .headers-region > .tab {
|
||||
-fx-background-color: -studio-border, -studio-surface;
|
||||
-fx-background-insets: 0, 2 2 0 2;
|
||||
-fx-background-radius: 0; -fx-padding: .4em .9em; -fx-border-width: 0;
|
||||
}
|
||||
.studio-tabs > .tab-header-area > .headers-region > .tab:hover {
|
||||
-fx-background-color: -studio-border, derive(-studio-surface, 12%);
|
||||
}
|
||||
.studio-tabs > .tab-header-area > .headers-region > .tab:selected {
|
||||
-fx-background-color: -studio-accent, -studio-workspace;
|
||||
}
|
||||
.studio-tabs > .tab-header-area > .headers-region > .tab:disabled { -fx-opacity: .45; }
|
||||
.studio-tabs .tab-label { -fx-text-fill: -studio-text; }
|
||||
.studio-tabs:focused > .tab-header-area > .headers-region > .tab:selected .focus-indicator {
|
||||
-fx-border-color: -studio-focus; -fx-border-width: 1; -fx-border-insets: 0; -fx-border-radius: 0;
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package p.studio.ui.javafx2.play;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class ViewportTransformTest {
|
||||
@Test void fitExpandsOrShrinksUniformlyAndWaitsForFrameDimensions(){
|
||||
assertEquals(1.5,ViewportTransform.fit(640,360,1100,540));
|
||||
assertEquals(.5,ViewportTransform.fit(640,360,320,500));
|
||||
assertEquals(0,ViewportTransform.fit(0,0,1000,600));
|
||||
}
|
||||
@Test void fractionalInputRejectsMarginsAndRightEdgeRatherThanClamping(){
|
||||
assertEquals(320,ViewportTransform.coordinate(480,960,640));
|
||||
assertEquals(639,ViewportTransform.coordinate(959.9,960,640));
|
||||
assertEquals(-1,ViewportTransform.coordinate(-.01,960,640));
|
||||
assertEquals(-1,ViewportTransform.coordinate(960,960,640));
|
||||
assertEquals(-1,ViewportTransform.coordinate(Double.NaN,960,640));
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package p.studio.ui.javafx2.window;
|
||||
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import p.studio.api.preferences.WindowGeometry;
|
||||
import java.util.List;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class WindowPlacementTest {
|
||||
@Test void preservesNegativeMonitorAndUsesItsSizeInsteadOfPrimary() {
|
||||
var screens=List.of(new Rectangle2D(0,30,1280,700),new Rectangle2D(-2560,-1440,2560,1440));
|
||||
var result=WindowPlacement.fit(new WindowGeometry(-2400,-1300,2000,1100,true),screens,680,480,1200,850);
|
||||
assertEquals(2000,result.width());assertEquals(-2400,result.x());assertTrue(result.maximized());
|
||||
}
|
||||
@Test void removedMonitorAndTinyScreenKeepWholeWindowReachable() {
|
||||
var result=WindowPlacement.fit(new WindowGeometry(-2400,-1300,2000,1100,false),
|
||||
List.of(new Rectangle2D(0,20,640,400)),680,480,1200,850);
|
||||
assertEquals(new WindowGeometry(0,20,640,400,false),result);
|
||||
}
|
||||
@Test void invalidDimensionsAndCoordinatesUseSafeDefaults() {
|
||||
var result=WindowPlacement.fit(new WindowGeometry(Double.NaN,Double.POSITIVE_INFINITY,-2,Double.NaN,false),
|
||||
List.of(new Rectangle2D(0,30,1920,1000)),680,480,1200,850);
|
||||
assertTrue(Double.isFinite(result.x()));assertTrue(result.y()>=30);assertEquals(1200,result.width());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user