@Override public void elementTriggered(Element element) { if (element.id == 0) { if (((GuiWorkspace) workspace).hasOpenProject()) { ((GuiWorkspace) workspace).getOpenProject().ghostModel = null; for (int i = 0; i < modelList.trees.size(); i++) { ElementListTree.Tree tree = modelList.trees.get(i); tree.selected = false; } } } if ((element.id == 1 || element.id == 3)) { for (int i = 0; i < modelList.trees.size(); i++) { ElementListTree.Tree tree = modelList.trees.get(i); if (tree.selected) { if (workspace.windowDragged == this) { workspace.windowDragged = null; } ProjectInfo project = ImportList.createProjectFromFile((File) tree.attachedObject); if (project == null) { workspace.addWindowOnTop( new WindowPopup(workspace, 0, 0, 180, 80, 180, 80, "window.open.failed") .putInMiddleOfScreen()); } else { project.repair(); if (((GuiWorkspace) workspace).hasOpenProject()) { if (((GuiWorkspace) workspace).getOpenProject().ghostModel != null) { ((GuiWorkspace) workspace).getOpenProject().ghostModel.destroy(); } ((GuiWorkspace) workspace).getOpenProject().ghostModel = project; for (Element e : elements) { if (e instanceof ElementToggle) { if (!((ElementToggle) e).toggledState) { project.bufferedTexture = null; } } else if (e instanceof ElementNumberInput) { ArrayList<CubeInfo> cubes = project.getAllCubes(); for (CubeInfo cube : cubes) { cube.opacity = Double.parseDouble(((ElementNumberInput) e).textFields.get(0).getText()); } } } } } break; } } workspace.removeWindow(this, true); } }
@Override public void update() { super.update(); if (!((GuiWorkspace) workspace).projectManager.projects.isEmpty()) { ProjectInfo info = ((GuiWorkspace) workspace) .projectManager.projects.get( ((GuiWorkspace) workspace).projectManager.selectedProject); listenTime++; if (listenTime > 20) { listenTime = 0; boolean shouldListen = false; for (Element e : elements) { if (e.id == 0) { shouldListen = ((ElementToggle) e).toggledState; } } if (shouldListen && info.textureFile != null && info.textureFile.exists()) { String md5 = IOUtil.getMD5Checksum(info.textureFile); if (md5 != null && !md5.equals(info.textureFileMd5)) { info.ignoreNextImage = true; info.textureFileMd5 = md5; BufferedImage image = null; try { image = ImageIO.read(info.textureFile); } catch (IOException e) { } if (!((GuiWorkspace) workspace).remoteSession) { Tabula.proxy.tickHandlerClient.mainframe.loadTexture(info.identifier, image, false); } else if (!((GuiWorkspace) workspace).sessionEnded && ((GuiWorkspace) workspace).isEditor) { ProjectHelper.sendTextureToServer( ((GuiWorkspace) workspace).host, info.identifier, false, image); } } } } if (info.bufferedTexture != this.image) { if (this.imageId != -1) { TextureUtil.deleteTexture(this.imageId); this.imageId = -1; } this.image = info.bufferedTexture; if (this.image != null) { this.imageId = TextureUtil.uploadTextureImage(TextureUtil.glGenTextures(), this.image); } } } }