use of mekanism.client.gui.element.window.GuiWindow in project Mekanism by mekanism.
the class GuiElementHandler method getGuiClickableAreas.
@Override
public Collection<IGuiClickableArea> getGuiClickableAreas(GuiMekanism<?> gui, double mouseX, double mouseY) {
// Make mouseX and mouseY not be relative
mouseX += gui.getGuiLeft();
mouseY += gui.getGuiTop();
GuiWindow guiWindow = gui.getWindowHovering(mouseX, mouseY);
if (guiWindow == null) {
// If no window is being hovered, then check the elements in general
return getGuiClickableArea(gui.children(), mouseX, mouseY);
}
// Otherwise, check the elements of the window
return getGuiClickableArea(guiWindow.children(), mouseX, mouseY);
}
use of mekanism.client.gui.element.window.GuiWindow in project Mekanism by mekanism.
the class GuiQIOItemViewer method transferWindows.
protected void transferWindows(Collection<GuiWindow> windows) {
for (GuiWindow window : windows) {
// Transition all current popup windows over to the new screen.
if (window instanceof GuiCraftingWindow) {
// Updating the references for listeners and the like for crafting windows
craftingWindowTab.adoptWindows(window);
// Update the container the virtual slots point to be correct
((GuiCraftingWindow) window).updateContainer(menu);
}
addWindow(window);
window.transferToNewGui(this);
}
}
use of mekanism.client.gui.element.window.GuiWindow in project Mekanism by mekanism.
the class GuiMekanism method removeWindow.
@Override
public void removeWindow(GuiWindow window) {
if (!windows.isEmpty()) {
GuiWindow top = windows.iterator().next();
windows.remove(window);
if (window == top) {
// If the window was the top window, make it lose focus
window.onFocusLost();
// Amd check if a new window is now in focus
GuiWindow newTop = windows.isEmpty() ? null : windows.iterator().next();
if (newTop == null) {
// If there isn't any because they have all been removed
// fire an "event" for any post all windows being closed
lastWindowRemoved();
} else {
// Otherwise, mark the new window as being focused
newTop.onFocused();
}
// Update the listener to being the window that is now selected or null if none are
setFocused(newTop);
}
}
}
use of mekanism.client.gui.element.window.GuiWindow in project Mekanism by mekanism.
the class GuiMekanism method addWindow.
@Override
public void addWindow(GuiWindow window) {
GuiWindow top = windows.isEmpty() ? null : windows.iterator().next();
if (top != null) {
top.onFocusLost();
}
windows.add(window);
window.onFocused();
}
use of mekanism.client.gui.element.window.GuiWindow in project Mekanism by mekanism.
the class GuiMekanism method mouseClicked.
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
hasClicked = true;
// first try to send the mouse event to our overlays
GuiWindow top = windows.isEmpty() ? null : windows.iterator().next();
GuiWindow focused = windows.stream().filter(overlay -> overlay.mouseClicked(mouseX, mouseY, button)).findFirst().orElse(null);
if (focused != null) {
if (windows.contains(focused)) {
// Validate that the focused window is still one of our windows, as if it wasn't focused/on top, and
// it is being closed, we don't want to update and mark it as focused, as our defocusing code won't
// run as we ran it when we pressed the button
setFocused(focused);
if (button == 0) {
setDragging(true);
}
// this check prevents us from moving the window to the top of the stack if the clicked window opened up an additional window
if (top != focused) {
top.onFocusLost();
windows.moveUp(focused);
focused.onFocused();
}
}
return true;
}
// otherwise, we send it to the current element
for (int i = buttons.size() - 1; i >= 0; i--) {
IGuiEventListener listener = buttons.get(i);
if (listener.mouseClicked(mouseX, mouseY, button)) {
setFocused(listener);
if (button == 0) {
setDragging(true);
}
return true;
}
}
return super.mouseClicked(mouseX, mouseY, button);
}
Aggregations