-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CATROID-825 "Set thread color to __" Brick #3942
Conversation
893627e
to
0732787
Compare
adc187b
to
665aaca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please increase the language version number.
Please change the parameter to a single string in hex-color format instead of the separate RGB colors.
d650218
to
af76be9
Compare
@@ -841,6 +842,7 @@ | |||
private List<Brick> setupEmbroideryCategoryList(Context context) { | |||
List<Brick> embroideryBrickList = new ArrayList<>(); | |||
embroideryBrickList.add(new StitchBrick()); | |||
embroideryBrickList.add(new SetThreadColorBrick(new Formula("0xff0000"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create a constant here, like for the other bricks
2006f01
to
56234d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot build because of conversion error, see in-context comment.
try { | ||
String colorStringInterpretation = "0xff0000"; | ||
if (color != null) { | ||
colorStringInterpretation = color.interpretString(sprite); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error, see https://jenkins.catrob.at/job/Catroid/job/PR-3942/32/execution/node/54/log/
21:42:56 > Task :catroid:compileStandaloneDebugJavaWithJavac
21:42:56 /home/catroid/jenkins_slave/workspace/Catroid_PR-
3942/catroid/src/main/java/org/catrobat/catroid/content/actions/SetThreadColorAction.java:44:
error: incompatible types: Sprite cannot be converted to Scope
21:42:56 colorStringInterpretation = color.interpretString(sprite);
Please also include my merge-conflict resolution commit for the Catrobat language version increase. |
catroid/src/main/java/org/catrobat/catroid/common/Constants.java
Outdated
Show resolved
Hide resolved
d5c3e19
to
43fad6e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately a crash happens when the color is not formatted as expected, and especially when it comes from the color picker: enter any color with the color picker in the formula editor:
After selecting the color, it looks like this:
The crash happens in SetThreadColorAction.java:49
Stacktrace:
03-20 19:26:10.909 E/AndroidRuntime(18805): FATAL EXCEPTION: GLThread 6642
03-20 19:26:10.909 E/AndroidRuntime(18805): Process: org.catrobat.catroid.independent_20210301_2128, PID: 18805
03-20 19:26:10.909 E/AndroidRuntime(18805): java.lang.StringIndexOutOfBoundsException: length=7; index=8
03-20 19:26:10.909 E/AndroidRuntime(18805): at java.lang.String.substring(String.java:2032)
03-20 19:26:10.909 E/AndroidRuntime(18805): at org.catrobat.catroid.content.actions.SetThreadColorAction.update(SetThreadColorAction.java:49)
03-20 19:26:10.909 E/AndroidRuntime(18805): at com.badlogic.gdx.scenes.scene2d.actions.TemporalAction.act(TemporalAction.java:55)
03-20 19:26:10.909 E/AndroidRuntime(18805): at com.badlogic.gdx.scenes.scene2d.actions.SequenceAction.act(SequenceAction.java:65)
03-20 19:26:10.909 E/AndroidRuntime(18805): at org.catrobat.catroid.common.ThreadScheduler.runThreadsForOneTick(ThreadScheduler.java:77)
03-20 19:26:10.909 E/AndroidRuntime(18805): at org.catrobat.catroid.common.ThreadScheduler.tick(ThreadScheduler.java:62)
03-20 19:26:10.909 E/AndroidRuntime(18805): at org.catrobat.catroid.content.Look.act(Look.java:207)
03-20 19:26:10.909 E/AndroidRuntime(18805): at com.badlogic.gdx.scenes.scene2d.Group.act(Group.java:49)
03-20 19:26:10.909 E/AndroidRuntime(18805): at com.badlogic.gdx.scenes.scene2d.Stage.act(Stage.java:222)
03-20 19:26:10.909 E/AndroidRuntime(18805): at org.catrobat.catroid.stage.StageListener.render(StageListener.java:542)
03-20 19:26:10.909 E/AndroidRuntime(18805): at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:494)
03-20 19:26:10.909 E/AndroidRuntime(18805): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1571)
03-20 19:26:10.909 E/AndroidRuntime(18805): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): uncaughtException:
03-20 19:26:10.909 E/BaseExceptionHandler(18805): java.lang.StringIndexOutOfBoundsException: length=7; index=8
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at java.lang.String.substring(String.java:2032)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at org.catrobat.catroid.content.actions.SetThreadColorAction.update(SetThreadColorAction.java:49)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at com.badlogic.gdx.scenes.scene2d.actions.TemporalAction.act(TemporalAction.java:55)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at com.badlogic.gdx.scenes.scene2d.actions.SequenceAction.act(SequenceAction.java:65)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at org.catrobat.catroid.common.ThreadScheduler.runThreadsForOneTick(ThreadScheduler.java:77)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at org.catrobat.catroid.common.ThreadScheduler.tick(ThreadScheduler.java:62)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at org.catrobat.catroid.content.Look.act(Look.java:207)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at com.badlogic.gdx.scenes.scene2d.Group.act(Group.java:49)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at com.badlogic.gdx.scenes.scene2d.Stage.act(Stage.java:222)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at org.catrobat.catroid.stage.StageListener.render(StageListener.java:542)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:494)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1571)
03-20 19:26:10.909 E/BaseExceptionHandler(18805): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)
Kotlin might have helped, as it is more difficult to leave exceptions uncaught.
One more issue: The selected color incorrectly persists over runs of the stage. For instance, look at the following code. The color of the thread in the first run is black for 5 seconds, then it switches to red. If you exit the stage and run the stage again, the thread will be red from the beginning. Only after you left the project and then restarted it completely will it revert to black.
@@ -180,6 +180,7 @@ | |||
public static final int STITCH_LENGTH = 10; | |||
public static final int ZIGZAG_STITCH_LENGTH = 2; | |||
public static final int ZIGZAG_STITCH_WIDTH = 10; | |||
public static final String THREAD_COLOR = "0xff0000"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static final String THREAD_COLOR = "0xff0000"; | |
public static final String THREAD_COLOR = "#ff0000"; |
We use the #XXXXXX format for colors in Catrobat, see all other color related bricks, and that's also what the color picker returns.
2bd7bd0
to
5b5ffee
Compare
Added Brick and Embroidery functionality. Also changed all tests regarding this.
Thanks! |
Added brick and embroidery support for it. Also changed all tests affected by the change to include a color parameter.
Your checklist for this pull request
Please review the contributing guidelines and wiki pages of this repository.