Skip to content

Commit 7de7596

Browse files
Scene editor: debug calls parameter and more about painting.
1 parent 33259c9 commit 7de7596

File tree

8 files changed

+54
-11
lines changed

8 files changed

+54
-11
lines changed

source/v2/phasereditor/phasereditor.scene.core/src/phasereditor/scene/core/SceneModel.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public class SceneModel {
7777
private String _createMethodName;
7878
private String _sceneKey;
7979
private SourceLang _compilerLang;
80+
private boolean _debugPaintCalls;
8081

8182
public enum MethodContextType {
8283
SCENE, OBJECT
@@ -121,8 +122,18 @@ public SceneModel() {
121122
_sceneKey = "";
122123

123124
_compilerLang = SourceLang.JAVA_SCRIPT_6;
125+
126+
_debugPaintCalls = false;
124127
}
125128

129+
public boolean isDebugPaintCalls() {
130+
return _debugPaintCalls;
131+
}
132+
133+
public void setDebugPaintCalls(boolean debugPaintCalls) {
134+
_debugPaintCalls = debugPaintCalls;
135+
}
136+
126137
public SourceLang getCompilerLang() {
127138
return _compilerLang;
128139
}
@@ -379,6 +390,9 @@ public void read(JSONObject data, IProject project) {
379390
_groupsModel.read(groupsData, project);
380391
}
381392
}
393+
{
394+
_debugPaintCalls = data.optBoolean("debugPaintCalls", false);
395+
}
382396
}
383397

384398
public void writeProperties(JSONObject data) {
@@ -409,6 +423,10 @@ public void writeProperties(JSONObject data) {
409423
data.put("methodContextType", _methodContextType.name());
410424
data.put("sceneKey", _sceneKey, "");
411425
}
426+
427+
{
428+
data.put("debugPaintCalls", _debugPaintCalls, false);
429+
}
412430
}
413431

414432
public void readProperties(JSONObject data) {

source/v2/phasereditor/phasereditor.scene.ui.editor.html/html/Editor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ namespace PhaserEditor2D {
432432
if (loadMsg.pack) {
433433
let scene = this.getObjectScene();
434434

435+
Editor.getInstance().stop();
435436
scene.load.once(Phaser.Loader.Events.COMPLETE,
436437

437438
(function (index2, list2) {
@@ -447,6 +448,7 @@ namespace PhaserEditor2D {
447448
scene.load.crossOrigin = "anonymous";
448449
scene.load.addPack(loadMsg.pack);
449450
scene.load.start();
451+
setTimeout( ()=> this.repaint(), 100);
450452
} else {
451453
this.processMessageList(index + 1, list);
452454
}

source/v2/phasereditor/phasereditor.scene.ui.editor.html/html/ToolScene.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace PhaserEditor2D {
4040

4141
this._selectionGraphics.depth = -1;
4242

43-
this._paintCallsLabel = this.add.text(10, 10, "", {"color": "black", "backgroundColor": "white"});
43+
this._paintCallsLabel = this.add.text(10, 10, "", { "color": "blue", "backgroundColor": "red" });
4444
this._paintCallsLabel.depth = 1000;
4545
}
4646

@@ -231,8 +231,13 @@ namespace PhaserEditor2D {
231231
this.renderSelection();
232232
this.updateTools();
233233

234-
this._paintCallsLabel.text = PAINT_COUNT.toString();
235-
PAINT_COUNT += 1;
234+
235+
this._paintCallsLabel.visible = Editor.getInstance().sceneProperties.debugPaintCalls;
236+
237+
if (this._paintCallsLabel.visible) {
238+
this._paintCallsLabel.text = PAINT_COUNT.toString();
239+
PAINT_COUNT += 1;
240+
}
236241
}
237242

238243
setTools(tools: InteractiveTool[]) {

source/v2/phasereditor/phasereditor.scene.ui.editor.html/html/out/Editor.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,12 @@ var PhaserEditor2D;
324324
};
325325
;
326326
Editor.prototype.onLoadAssets = function (index, list) {
327+
var _this = this;
327328
var loadMsg = list[index];
328329
var self = this;
329330
if (loadMsg.pack) {
330331
var scene = this.getObjectScene();
332+
Editor.getInstance().stop();
331333
scene.load.once(Phaser.Loader.Events.COMPLETE, (function (index2, list2) {
332334
return function () {
333335
consoleLog("Loader complete.");
@@ -339,6 +341,7 @@ var PhaserEditor2D;
339341
scene.load.crossOrigin = "anonymous";
340342
scene.load.addPack(loadMsg.pack);
341343
scene.load.start();
344+
setTimeout(function () { return _this.repaint(); }, 100);
342345
}
343346
else {
344347
this.processMessageList(index + 1, list);

source/v2/phasereditor/phasereditor.scene.ui.editor.html/html/out/ToolScene.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var PhaserEditor2D;
4343
}
4444
});
4545
this._selectionGraphics.depth = -1;
46-
this._paintCallsLabel = this.add.text(10, 10, "", { "color": "black", "backgroundColor": "white" });
46+
this._paintCallsLabel = this.add.text(10, 10, "", { "color": "blue", "backgroundColor": "red" });
4747
this._paintCallsLabel.depth = 1000;
4848
};
4949
ToolScene.prototype.initCamera = function () {
@@ -172,8 +172,11 @@ var PhaserEditor2D;
172172
this.renderAxis();
173173
this.renderSelection();
174174
this.updateTools();
175-
this._paintCallsLabel.text = PAINT_COUNT.toString();
176-
PAINT_COUNT += 1;
175+
this._paintCallsLabel.visible = PhaserEditor2D.Editor.getInstance().sceneProperties.debugPaintCalls;
176+
if (this._paintCallsLabel.visible) {
177+
this._paintCallsLabel.text = PAINT_COUNT.toString();
178+
PAINT_COUNT += 1;
179+
}
177180
};
178181
ToolScene.prototype.setTools = function (tools) {
179182
for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {

source/v2/phasereditor/phasereditor.scene.ui.editor.html/html/out/workaround.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ window.addEventListener("onerror", function (e) {
22
alert("WebView ERROR: " + e);
33
});
44
window.AudioContext = function () { };
5-
var CONSOLE_LOG = true;
5+
var CONSOLE_LOG = false;
66
function consoleLog(msg) {
77
if (CONSOLE_LOG) {
88
console.log(msg);

source/v2/phasereditor/phasereditor.scene.ui.editor.html/html/workaround.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ window.addEventListener("onerror", function (e) {
77

88

99
// disable log on production
10-
var CONSOLE_LOG = true;
10+
var CONSOLE_LOG = false;
1111
function consoleLog(msg: any) {
1212
if (CONSOLE_LOG) {
1313
console.log(msg);

source/v2/phasereditor/phasereditor.scene.ui.editor/src/phasereditor/scene/ui/editor/properties/WebViewSection.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public boolean canEdit(Object obj) {
5454
@Override
5555
public Control createContent(Composite parent) {
5656
var comp = new Composite(parent, 0);
57-
comp.setLayout(new GridLayout(1, false));
57+
comp.setLayout(new GridLayout(2, false));
5858

5959
{
6060
var btn = new Button(comp, SWT.PUSH);
61-
btn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
61+
btn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
6262
btn.setText("System Browser");
6363
btn.setImage(EditorSharedImages.getImage(IMG_WORLD));
6464
btn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
@@ -68,7 +68,19 @@ public Control createContent(Composite parent) {
6868

6969
{
7070
var btn = createRefreshButton(comp, getEditor());
71-
btn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
71+
btn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
72+
}
73+
74+
{
75+
label(comp, "Debug Paint Calls",
76+
"*Check to count how many paint calls are requested.\nPaint calls should be requested by demand, not in a loop.");
77+
var btn = new Button(comp, SWT.CHECK);
78+
addUpdate(() -> {
79+
btn.setSelection(getSceneModel().isDebugPaintCalls());
80+
});
81+
btn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
82+
wrapOperation(() -> getSceneModel().setDebugPaintCalls(btn.getSelection()));
83+
}));
7284
}
7385

7486
return comp;

0 commit comments

Comments
 (0)