Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
963df18
Add warning limit for import on sprites
Bouh May 2, 2020
0099d96
Revert "Add warning limit for import on sprites"
Bouh May 2, 2020
8d34ef4
Try promise
Bouh May 8, 2020
2566ded
Icon warning in thumbnail
Bouh May 8, 2020
ca0faf2
Fix NaN
Bouh May 9, 2020
fa66f56
Warning message about sprite in resources
Bouh May 9, 2020
5e51d23
Add icons in resources
Bouh May 9, 2020
578f60e
Prettier
Bouh May 9, 2020
2d4a552
Refactor with callback & add tooltip
Bouh May 10, 2020
2997eb2
Stylize Warning and Error thumbnail
Bouh May 14, 2020
a179365
Remove useless content
Bouh May 14, 2020
5124d39
Prettier
Bouh May 14, 2020
a96cf0f
Avoid new render with useCallback()
Bouh May 23, 2020
1b8048e
Merge branch 'master' into importer_limit
Bouh May 23, 2020
7162d13
Merge branch 'master' into importer_limit
Bouh May 23, 2020
01e2bd8
Use ResourcesLoader for save the state for each resources
Bouh Jun 3, 2020
7358195
Add watcher on resources
Bouh Jun 12, 2020
5ca9064
Watcher trigger status on resources, it's used for display warnings
Bouh Jun 12, 2020
9473dc2
Merge branch 'master' into importer_limit
Bouh Jun 12, 2020
eb52354
Merge branch 'master' into importer_limit
Bouh Jun 24, 2020
5368b83
Use Chokidar
Bouh Jul 7, 2020
e64d193
Revert "Use Chokidar"
Bouh Jul 7, 2020
cb2823f
Use Chokidar
Bouh Jul 7, 2020
142dd74
Fix crash and make burstURL public
Bouh Jul 7, 2020
154c6d9
Avoid the warning message again if it's already noted with a warning
Bouh Jul 7, 2020
4face52
Get resources status for the list in the resource tab
Bouh Jul 7, 2020
f4477a8
Fix crash in Ressources tab
Bouh Jul 22, 2020
398d23b
Merge branch 'master' into importer_limit
Bouh Jul 22, 2020
a7a8680
Merge branch 'master' into importer_limit
Bouh Oct 4, 2020
4e573f9
Fix compatibility code with master branch
Bouh Oct 4, 2020
2711428
Merge branch 'master' into importer_limit
Bouh Feb 27, 2021
bd89232
Merge from master
Bouh Feb 27, 2021
0588977
.
Bouh Feb 27, 2021
6a6b8a1
Experiment refresh resources on scene editor with watcher
Bouh Feb 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GDJS/Runtime/pixi-renderers/runtimegame-pixi-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ namespace gdjs {
};
// @ts-ignore
renderer.view.onwheel = function (event) {
manager.onMouseWheel(event.deltaY);
manager.onMouseWheel(-event.deltaY);
};

//Touches
Expand Down
2 changes: 1 addition & 1 deletion newIDE/app/src/InstancesEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default class InstancesEditor extends Component<Props> {

this.pixiRenderer.view.onwheel = event => {
if (this.keyboardShortcuts.shouldZoom()) {
this.zoomBy(event.deltaY / 5000);
this.zoomBy(-event.deltaY / 5000);
} else if (this.keyboardShortcuts.shouldScrollHorizontally()) {
this.viewPosition.scrollBy(-event.deltaY / 10, 0);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export class ResourcesEditorContainer extends React.Component<RenderEditorContai
}

forceUpdateEditor() {
// No updates to be done.
console.log('forceUpdateEditor resource editor container');
const { resources } = this.props;
if (this.editor && resources) this.editor.updateResources(resources);
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export class SceneEditorContainer extends React.Component<RenderEditorContainerP
}

forceUpdateEditor() {
if (this.editor) this.editor.forceUpdateObjectsList();
console.log('forceUpdateEditor scene editor container');
const { resources } = this.props;
if (this.editor && resources) this.editor.updateResources(resources);
}

getLayout(): ?gdLayout {
Expand Down Expand Up @@ -93,6 +95,7 @@ export class SceneEditorContainer extends React.Component<RenderEditorContainerP
ref={editor => (this.editor = editor)}
project={project}
layout={layout}
resources={this.props.resources}
initialInstances={layout.getInitialInstances()}
initialUiSettings={serializeToJSObject(layout.getAssociatedSettings())}
isActive={isActive}
Expand Down
4 changes: 4 additions & 0 deletions newIDE/app/src/MainFrame/Preferences/PreferencesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export type PreferencesValues = {|
autosaveOnPreview: boolean,
useNewInstructionEditorDialog: boolean,
useGDJSDevelopmentWatcher: boolean,
useResourcesWatcher: boolean,
eventsSheetUseAssignmentOperators: boolean,
showEffectParameterNames: boolean,
projectLastUsedPaths: { [string]: { [ResourceKind]: string } },
Expand Down Expand Up @@ -203,6 +204,7 @@ export type Preferences = {|
setAutosaveOnPreview: (enabled: boolean) => void,
setUseNewInstructionEditorDialog: (enabled: boolean) => void,
setUseGDJSDevelopmentWatcher: (enabled: boolean) => void,
setUseResourcesWatcher: (enabled: boolean) => void,
setEventsSheetUseAssignmentOperators: (enabled: boolean) => void,
setShowEffectParameterNames: (enabled: boolean) => void,
getLastUsedPath: (project: gdProject, kind: ResourceKind) => string,
Expand Down Expand Up @@ -253,6 +255,7 @@ export const initialPreferences = {
autosaveOnPreview: true,
useNewInstructionEditorDialog: true,
useGDJSDevelopmentWatcher: true,
useResourcesWatcher: true,
eventsSheetUseAssignmentOperators: false,
showEffectParameterNames: false,
projectLastUsedPaths: {},
Expand All @@ -277,6 +280,7 @@ export const initialPreferences = {
setAutosaveOnPreview: () => {},
setUseNewInstructionEditorDialog: (enabled: boolean) => {},
setUseGDJSDevelopmentWatcher: (enabled: boolean) => {},
setUseResourcesWatcher: (enabled: boolean) => {},
setEventsSheetUseAssignmentOperators: (enabled: boolean) => {},
setShowEffectParameterNames: (enabled: boolean) => {},
getLastUsedPath: (project: gdProject, kind: ResourceKind) => '',
Expand Down
42 changes: 29 additions & 13 deletions newIDE/app/src/MainFrame/Preferences/PreferencesDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const PreferencesDialog = ({ i18n, onClose }: Props) => {
setAutosaveOnPreview,
setUseNewInstructionEditorDialog,
setUseGDJSDevelopmentWatcher,
setUseResourcesWatcher,
setEventsSheetUseAssignmentOperators,
getDefaultEditorMosaicNode,
setDefaultEditorMosaicNode,
Expand Down Expand Up @@ -256,19 +257,34 @@ const PreferencesDialog = ({ i18n, onClose }: Props) => {
/>
</Line>
{Window.isDev() && (
<Line>
<Toggle
onToggle={(e, check) => setUseGDJSDevelopmentWatcher(check)}
toggled={values.useGDJSDevelopmentWatcher}
labelPosition="right"
label={
<Trans>
Watch changes in game engine (GDJS) sources and auto import
them (dev only)
</Trans>
}
/>
</Line>
<div>
<Line>
<Toggle
onToggle={(e, check) => setUseGDJSDevelopmentWatcher(check)}
toggled={values.useGDJSDevelopmentWatcher}
labelPosition="right"
label={
<Trans>
Watch changes in game engine (GDJS) sources and auto
import them (dev only)
</Trans>
}
/>
</Line>
<Line>
<Toggle
onToggle={(e, check) => setUseResourcesWatcher(check)}
toggled={values.useResourcesWatcher}
labelPosition="right"
label={
<Trans>
Watch changes in resources and check the possible warning
on them (dev only because WIP)
</Trans>
}
/>
</Line>
</div>
)}
</Column>
)}
Expand Down
13 changes: 13 additions & 0 deletions newIDE/app/src/MainFrame/Preferences/PreferencesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class PreferencesProvider extends React.Component<Props, State> {
this
),
setUseGDJSDevelopmentWatcher: this._setUseGDJSDevelopmentWatcher.bind(this),
setUseResourcesWatcher: this._setUseResourcesWatcher.bind(this),
setEventsSheetUseAssignmentOperators: this._setEventsSheetUseAssignmentOperators.bind(
this
),
Expand Down Expand Up @@ -141,6 +142,18 @@ export default class PreferencesProvider extends React.Component<Props, State> {
);
}

_setUseResourcesWatcher(useResourcesWatcher: boolean) {
this.setState(
state => ({
values: {
...state.values,
useResourcesWatcher,
},
}),
() => this._persistValuesToLocalStorage(this.state)
);
}

_setEventsSheetUseAssignmentOperators(
eventsSheetUseAssignmentOperators: boolean
) {
Expand Down
24 changes: 24 additions & 0 deletions newIDE/app/src/MainFrame/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ import {
import { type HotReloadPreviewButtonProps } from '../HotReload/HotReloadPreviewButton';
import HotReloadLogsDialog from '../HotReload/HotReloadLogsDialog';
import { useDiscordRichPresence } from '../Utils/UpdateDiscordRichPresence';
import { ResourcesWatcher } from '../ResourcesLoader/ResourcesWatcher.js';
import { useResourceFetcher } from '../ProjectsStorage/ResourceFetcher';
import { delay } from '../Utils/Delay';
import { type ExtensionShortHeader } from '../Utils/GDevelopServices/Extension';
import PixiResourcesLoader from '../ObjectsRendering/PixiResourcesLoader';

const GD_STARTUP_TIMES = global.GD_STARTUP_TIMES || [];

Expand Down Expand Up @@ -2110,6 +2112,7 @@ const MainFrame = (props: Props) => {
isActive: isCurrentTab,
extraEditorProps: editorTab.extraEditorProps,
project: currentProject,
resources: state.resources,
ref: editorRef => (editorTab.editorRef = editorRef),
setToolbar: setEditorToolbar,
onChangeSubscription: () => openSubscriptionDialog(true),
Expand Down Expand Up @@ -2347,6 +2350,27 @@ const MainFrame = (props: Props) => {
{state.gdjsDevelopmentWatcherEnabled &&
renderGDJSDevelopmentWatcher &&
renderGDJSDevelopmentWatcher()}

{state.currentProject && (
<ResourcesWatcher
project={state.currentProject}
updateResource={resources => {
setState(state => ({
...state,
resources: resources,
}));

const editorTab = getCurrentTab(state.editorTabs);
if (editorTab && editorTab.editorRef) {
PixiResourcesLoader.deleteResourcesCache(
state.currentProject,
resources
);
editorTab.editorRef.forceUpdateEditor();
}
}}
/>
)}
{!!hotReloadLogs.length && (
<HotReloadLogsDialog
logs={hotReloadLogs}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,21 @@ const AddSpriteButton = SortableElement(({ displayHint, onAdd }) => {
});

const SortableSpriteThumbnail = SortableElement(
({ sprite, project, resourcesLoader, selected, onSelect, onContextMenu }) => {
({
sprite,
project,
resourcesLoader,
selected,
onDelete,
onSelect,
onContextMenu,
}) => {
return (
<ImageThumbnail
selectable
selected={selected}
onSelect={onSelect}
deleteSprite={onDelete}
onContextMenu={onContextMenu}
resourceName={sprite.getImageName()}
resourcesLoader={resourcesLoader}
Expand All @@ -89,6 +98,7 @@ const SortableList = SortableContainer(
project,
resourcesLoader,
onAddSprite,
onDeleteSprite,
selectedSprites,
onSelectSprite,
onSpriteContextMenu,
Expand All @@ -107,6 +117,7 @@ const SortableList = SortableContainer(
selected={!!selectedSprites[sprite.ptr]}
onContextMenu={(x, y) => onSpriteContextMenu(x, y, sprite)}
onSelect={selected => onSelectSprite(sprite, selected)}
onDelete={selected => onDeleteSprite(i)}
resourcesLoader={resourcesLoader}
project={project}
/>
Expand Down Expand Up @@ -178,6 +189,12 @@ export default class SpritesList extends Component<Props, void> {
this.forceUpdate();
};

onDeleteSprite = (spriteIndex: number) => {
const { direction } = this.props;

direction.removeSprite(spriteIndex);
};

onAddSprite = () => {
const {
resourceSources,
Expand Down Expand Up @@ -327,6 +344,7 @@ export default class SpritesList extends Component<Props, void> {
project={this.props.project}
onSortEnd={this.onSortEnd}
onAddSprite={this.onAddSprite}
onDeleteSprite={this.onDeleteSprite}
selectedSprites={this.props.selectedSprites}
onSelectSprite={this.props.onSelectSprite}
onSpriteContextMenu={this.props.onSpriteContextMenu}
Expand Down
45 changes: 36 additions & 9 deletions newIDE/app/src/ObjectsRendering/PixiResourcesLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export default class PixiResourcesLoader {
texture.baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST;
}
}
static deleteResourcesCache(project: gdProject, resources: Array<string>) {
ResourcesLoader.burstUrlsCacheForResources(project, resources);
}

/**
* (Re)load the PIXI texture represented by the given resources.
Expand Down Expand Up @@ -69,17 +72,28 @@ export default class PixiResourcesLoader {

loader.load((loader, loadedResources) => {
loader.onProgress.detach(progressCallbackId);

//Store the loaded textures so that they are ready to use.
for (const resourceName in loadedResources) {
if (loadedResources.hasOwnProperty(resourceName)) {
const resource = resourcesManager.getResource(resourceName);
if (resource.getKind() !== 'image') continue;

loadedTextures[resourceName] = loadedResources[resourceName].texture;
let statusCode = '';
if (
loadedResources[resourceName].texture.baseTexture.realWidth >
2048 ||
loadedResources[resourceName].texture.baseTexture.realHeight > 2048
) {
statusCode = 'WARNING_IMAGE_EXCEEDED_2048_PIXELS';
console.log('TROP GRAND 2');
}
loadedTextures[resourceName] = {
pixi: loadedResources[resourceName].texture,
statusCode: statusCode,
};
ResourcesLoader.setStatusCode(project, resourceName, statusCode);
PixiResourcesLoader._initializeTexture(
resource,
loadedTextures[resourceName]
loadedTextures[resourceName].pixi
);
}
}
Expand All @@ -97,7 +111,7 @@ export default class PixiResourcesLoader {
*/
static getPIXITexture(project: gdProject, resourceName: string) {
if (loadedTextures[resourceName]) {
return loadedTextures[resourceName];
return loadedTextures[resourceName].pixi;
}

if (!project.getResourcesManager().hasResource(resourceName))
Expand All @@ -114,7 +128,7 @@ export default class PixiResourcesLoader {

PixiResourcesLoader._initializeTexture(
resource,
loadedTextures[resourceName]
loadedTextures[resourceName].pixi
);
return loadedTextures[resourceName];
}
Expand All @@ -128,15 +142,14 @@ export default class PixiResourcesLoader {
*/
static getPIXIVideoTexture(project: gdProject, resourceName: string) {
if (loadedTextures[resourceName]) {
return loadedTextures[resourceName];
return loadedTextures[resourceName].pixi;
}

if (!project.getResourcesManager().hasResource(resourceName))
return invalidTexture;

const resource = project.getResourcesManager().getResource(resourceName);
if (resource.getKind() !== 'video') return invalidTexture;

loadedTextures[resourceName] = PIXI.Texture.from(
ResourcesLoader.getResourceFullUrl(project, resourceName, {
disableCacheBurst: true, // Disable cache bursting for video because it prevent the video to be recognized as such (for a local file)
Expand All @@ -149,7 +162,6 @@ export default class PixiResourcesLoader {
},
}
);

return loadedTextures[resourceName];
}

Expand Down Expand Up @@ -222,6 +234,21 @@ export default class PixiResourcesLoader {
return invalidTexture;
}

static setResourceStatusCode(project: gdProject, resourceName: string) {
let statusCode = '';
if (
loadedTextures[resourceName].pixi.texture.baseTexture.realWidth > 2048 ||
loadedTextures[resourceName].pixi.texture.baseTexture.realHeight > 2048
) {
statusCode = 'WARNING_IMAGE_EXCEEDED_2048_PIXELS';
}
return (loadedTextures[resourceName].statusCode = statusCode);
}

static getResourceStatusCode(project: gdProject, resourceName: string) {
if (!loadedTextures[resourceName].statusCode) return;
return loadedTextures[resourceName].statusCode;
}
/**
* Get the the data from a json resource in the IDE.
*/
Expand Down
Loading