UnderwaterApps / overlap2d

Overlap2D Game development toolkit for UI and Level design
Other
782 stars 224 forks source link

No notification & crash on incorrect 9patch import #332

Open arnoid opened 8 years ago

arnoid commented 8 years ago

I've been trying to use 9patches generated by this website http://android-holo-colors.com/

Unfortunately some files contain red borders in the patch zone. Like in this file one

While red border is for "visual" content ordering in latest android, it is ignored in other cases.

Steps to reproduce 1.When i try import this resource with "drag&drop" or "browse" nothing happens. At least visually.

  1. Click repack
  2. app crashes with such stacktrace

java.lang.RuntimeException: Invalid /Users/sergii/work/workspace/pandorum/design-ui/assets/orig/images/appthemebtndefaultdisabledfocusedholodark ninepatch split pixel at 2, 97, rgba: 255, 0, 0, 255 at com.badlogic.gdx.tools.texturepacker.ImageProcessor.splitError(ImageProcessor.java:266) at com.badlogic.gdx.tools.texturepacker.ImageProcessor.getSplitPoint(ImageProcessor.java:403) at com.badlogic.gdx.tools.texturepacker.ImageProcessor.getPads(ImageProcessor.java:327) at com.badlogic.gdx.tools.texturepacker.ImageProcessor.processImage(ImageProcessor.java:148) at com.badlogic.gdx.tools.texturepacker.ImageProcessor.addImage(ImageProcessor.java:94) at com.badlogic.gdx.tools.texturepacker.ImageProcessor.addImage(ImageProcessor.java:87) at com.badlogic.gdx.tools.texturepacker.TexturePacker.pack(TexturePacker.java:101) at com.uwsoft.editor.proxy.ResolutionManager.rePackProjectImages(ResolutionManager.java:364) at com.uwsoft.editor.proxy.ResolutionManager.rePackProjectImagesForAllResolutions(ResolutionManager.java:474) at com.uwsoft.editor.view.ui.box.UIResolutionBoxMediator.handleNotification(UIResolutionBoxMediator.java:101) at com.puremvc.patterns.observer.BaseObserver.notifyObserver(BaseObserver.java:82) at com.puremvc.core.CoreView.notifyObservers(CoreView.java:128) at com.puremvc.patterns.facade.SimpleFacade.notifyObservers(SimpleFacade.java:361) at com.puremvc.patterns.facade.SimpleFacade.sendNotification(SimpleFacade.java:323) at com.puremvc.patterns.facade.SimpleFacade.sendNotification(SimpleFacade.java:350) at com.uwsoft.editor.view.ui.box.UIResolutionBox$UIResolutionBoxButtonClickListener.clicked(UIResolutionBox.java:120) at com.badlogic.gdx.scenes.scene2d.utils.ClickListener.touchUp(ClickListener.java:89) at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:58) at com.badlogic.gdx.scenes.scene2d.Stage.touchUp(Stage.java:348) at com.badlogic.gdx.InputMultiplexer.touchUp(InputMultiplexer.java:96) at com.badlogic.gdx.backends.jglfw.JglfwInput$1.touchUp(JglfwInput.java:91) at com.badlogic.gdx.InputProcessorQueue.drain(InputProcessorQueue.java:80) at com.badlogic.gdx.backends.jglfw.JglfwInput.update(JglfwInput.java:137) at com.badlogic.gdx.backends.jglfw.JglfwApplication.frame(JglfwApplication.java:213) at com.badlogic.gdx.backends.jglfw.JglfwApplication.start(JglfwApplication.java:198) at com.badlogic.gdx.backends.jglfw.JglfwApplication.initialize(JglfwApplication.java:178) at com.badlogic.gdx.backends.jglfw.JglfwApplication$1.run(JglfwApplication.java:87) at java.lang.Thread.run(Thread.java:745)

What do i request:

P.S. I've created small tool for red border removal https://github.com/arnoid/ninepatch-red-removal

azakhary commented 8 years ago

Hmm interesting case, never encountered this format. We should definitely handle the crash. But I think it should not be hard to support importing this.

azakhary commented 8 years ago

Btw, did you knew that you can use Overlap2D plugin that comes with the editor, to edit 9 patches directly inside the editor? just import any non 9patch image, and right click on it, and choose Convert to 9patch

arnoid commented 8 years ago

I did not, cos' i was not able to import 9path with red marks :smile: . Anyways a have around 60 images, so it was easier to build a "fixing" tool

arnoid commented 8 years ago

I've checked the https://github.com/libgdx/libgdx/blob/fde893cec5448fdd09e778d1c103aac474950873/extensions/gdx-tools/src/com/badlogic/gdx/tools/texturepacker/ImageProcessor.java

            if (!startPoint && (rgba[0] != 0 || rgba[1] != 0 || rgba[2] != 0 || rgba[3] != 255)) splitError(x, y, rgba, name);

And it seems that this kind of behaviour (either black, either transparent) is hardcoded.

I'll try to create a pull request for libgdx to extract this for extensibility.

arnoid commented 8 years ago

I've created pull request into libgdx with fix https://github.com/libgdx/libgdx/pull/3643