rename elementManager->elementService

This commit is contained in:
austin 2024-08-29 20:09:37 -04:00
parent 5fe6b7a3c4
commit 11dfc5bceb
18 changed files with 111 additions and 111 deletions

View File

@ -961,9 +961,9 @@ public class ControlHandler {
// Window mainMenuWindow = new Window(0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
Window mainMenuInGame = MenuGeneratorsInGame.createInGameMainMenu();
// mainMenuWindow.addChild(mainMenuInGame);
Globals.elementManager.registerWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, mainMenuInGame);
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), true);
Globals.elementManager.focusFirstElement();
Globals.elementService.registerWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN, mainMenuInGame);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), true);
Globals.elementService.focusFirstElement();
Globals.controlHandler.hintUpdateControlState(ControlsState.IN_GAME_MAIN_MENU);
//play sound effect
if(Globals.virtualAudioSourceManager != null){
@ -978,14 +978,14 @@ public class ControlHandler {
mainGameControlList.add(controls.get(INPUT_CODE_INVENTORY_OPEN));
inventoryControlList.add(controls.get(INPUT_CODE_INVENTORY_OPEN));
controls.get(INPUT_CODE_INVENTORY_OPEN).setOnClick(new ControlMethod(){public void execute(){
if(InventoryUtils.hasNaturalInventory(Globals.playerEntity) && Globals.elementManager.getWindow(WindowUtils.getInventoryWindowID(InventoryUtils.getNaturalInventory(Globals.playerEntity).getId())) == null){
if(InventoryUtils.hasNaturalInventory(Globals.playerEntity) && Globals.elementService.getWindow(WindowUtils.getInventoryWindowID(InventoryUtils.getNaturalInventory(Globals.playerEntity).getId())) == null){
//create window
UnrelationalInventoryState inventory = InventoryUtils.getNaturalInventory(Globals.playerEntity);
Window mainMenuWindow = MenuGeneratorsInventory.createNaturalInventoryMenu(inventory);
//register
Globals.elementManager.registerWindow(WindowUtils.getInventoryWindowID(inventory.getId()), mainMenuWindow);
Globals.elementService.registerWindow(WindowUtils.getInventoryWindowID(inventory.getId()), mainMenuWindow);
//make visible
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowUtils.getInventoryWindowID(inventory.getId())), true);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowUtils.getInventoryWindowID(inventory.getId())), true);
//controls
Globals.controlHandler.hintUpdateControlState(ControlsState.INVENTORY);
//play sound effect
@ -994,8 +994,8 @@ public class ControlHandler {
}
//
Globals.openInventoriesCount++;
} else if(InventoryUtils.hasNaturalInventory(Globals.playerEntity) && Globals.elementManager.getWindow(WindowUtils.getInventoryWindowID(InventoryUtils.getNaturalInventory(Globals.playerEntity).getId())) != null){
Globals.elementManager.closeWindow(WindowUtils.getInventoryWindowID(InventoryUtils.getNaturalInventory(Globals.playerEntity).getId()));
} else if(InventoryUtils.hasNaturalInventory(Globals.playerEntity) && Globals.elementService.getWindow(WindowUtils.getInventoryWindowID(InventoryUtils.getNaturalInventory(Globals.playerEntity).getId())) != null){
Globals.elementService.closeWindow(WindowUtils.getInventoryWindowID(InventoryUtils.getNaturalInventory(Globals.playerEntity).getId()));
}
}});
controls.get(INPUT_CODE_INVENTORY_OPEN).setRepeatTimeout(0.5f * Main.targetFrameRate);
@ -1006,13 +1006,13 @@ public class ControlHandler {
mainGameControlList.add(controls.get(INPUT_CODE_CHARACTER_OPEN));
inventoryControlList.add(controls.get(INPUT_CODE_CHARACTER_OPEN));
controls.get(INPUT_CODE_CHARACTER_OPEN).setOnClick(new ControlMethod(){public void execute(){
if(InventoryUtils.hasEquipInventory(Globals.playerEntity) && Globals.elementManager.getWindow(WindowStrings.WINDOW_CHARACTER) == null){
if(InventoryUtils.hasEquipInventory(Globals.playerEntity) && Globals.elementService.getWindow(WindowStrings.WINDOW_CHARACTER) == null){
//create window
Window characterInventoryMenu = MenuGeneratorsInventory.createCharacterInventoryMenu(InventoryUtils.getEquipInventory(Globals.playerEntity));
//register
Globals.elementManager.registerWindow(WindowStrings.WINDOW_CHARACTER, characterInventoryMenu);
Globals.elementService.registerWindow(WindowStrings.WINDOW_CHARACTER, characterInventoryMenu);
//make visible
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_CHARACTER), true);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_CHARACTER), true);
//controls
Globals.controlHandler.hintUpdateControlState(ControlsState.INVENTORY);
//play sound effect
@ -1021,8 +1021,8 @@ public class ControlHandler {
}
//
Globals.openInventoriesCount++;
} else if(InventoryUtils.hasEquipInventory(Globals.playerEntity) && Globals.elementManager.getWindow(WindowStrings.WINDOW_CHARACTER) != null){
Globals.elementManager.closeWindow(WindowStrings.WINDOW_CHARACTER);
} else if(InventoryUtils.hasEquipInventory(Globals.playerEntity) && Globals.elementService.getWindow(WindowStrings.WINDOW_CHARACTER) != null){
Globals.elementService.closeWindow(WindowStrings.WINDOW_CHARACTER);
}
}});
controls.get(INPUT_CODE_CHARACTER_OPEN).setRepeatTimeout(0.5f * Main.targetFrameRate);
@ -1132,13 +1132,13 @@ public class ControlHandler {
menuNavigationControlList.add(controls.get(DATA_STRING_INPUT_CODE_MENU_NAVIGATE_FORWARD));
controls.get(DATA_STRING_INPUT_CODE_MENU_NAVIGATE_FORWARD).setOnPress(new ControlMethod(){public void execute(){
// Globals.currentMenu.incrementMenuOption();
Globals.elementManager.focusNextElement();
Globals.elementService.focusNextElement();
}});
menuNavigationControlList.add(controls.get(DATA_STRING_INPUT_CODE_MENU_NAVIGATE_BACKWARDS));
controls.get(DATA_STRING_INPUT_CODE_MENU_NAVIGATE_BACKWARDS).setOnPress(new ControlMethod(){public void execute(){
// Globals.currentMenu.decrementMenuOption();
Globals.elementManager.focusPreviousElement();
Globals.elementService.focusPreviousElement();
}});
@ -1146,17 +1146,17 @@ public class ControlHandler {
//Incrementing a menu element
menuNavigationControlList.add(controls.get(DATA_STRING_INPUT_CODE_MENU_INCREMENT));
controls.get(DATA_STRING_INPUT_CODE_MENU_INCREMENT).setOnPress(new ControlMethod(){public void execute(){
Globals.elementManager.fireEvent(
Globals.elementService.fireEvent(
new MenuEvent(MenuEventType.INCREMENT),
Globals.elementManager.getFocusedElement().getAbsoluteX(),
Globals.elementManager.getFocusedElement().getAbsoluteY()
Globals.elementService.getFocusedElement().getAbsoluteX(),
Globals.elementService.getFocusedElement().getAbsoluteY()
);
}});
controls.get(DATA_STRING_INPUT_CODE_MENU_INCREMENT).setOnRepeat(new ControlMethod(){public void execute(){
Globals.elementManager.fireEvent(
Globals.elementService.fireEvent(
new MenuEvent(MenuEventType.INCREMENT),
Globals.elementManager.getFocusedElement().getAbsoluteX(),
Globals.elementManager.getFocusedElement().getAbsoluteY()
Globals.elementService.getFocusedElement().getAbsoluteX(),
Globals.elementService.getFocusedElement().getAbsoluteY()
);
}});
controls.get(DATA_STRING_INPUT_CODE_MENU_INCREMENT).setRepeatTimeout(0.5f * Main.targetFrameRate);
@ -1164,13 +1164,13 @@ public class ControlHandler {
//moving the mouse
menuNavigationControlList.add(controls.get(MENU_MOUSE_MOVE));
controls.get(MENU_MOUSE_MOVE).setOnMove(new Control.MouseCallback(){public void execute(MouseEvent mouseEvent){
Globals.elementManager.updateHover(mouseEvent.getCurrentX(), mouseEvent.getCurrentY());
Globals.elementService.updateHover(mouseEvent.getCurrentX(), mouseEvent.getCurrentY());
}});
//scrolling the mouse
menuNavigationControlList.add(controls.get(MENU_SCROLL));
controls.get(MENU_SCROLL).setOnScroll(new Control.ScrollCallback() {public void execute(ScrollEvent scrollEvent){
Globals.elementManager.fireEvent(scrollEvent, GLFW_KEY_X, GLFW_KEY_Z);
Globals.elementService.fireEvent(scrollEvent, GLFW_KEY_X, GLFW_KEY_Z);
}});
//dragging the cursor
@ -1181,7 +1181,7 @@ public class ControlHandler {
if(dragging){
dragging = false;
//fire dragrelease event to elementmanager
Globals.elementManager.dragRelease((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
Globals.elementService.dragRelease((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
}
}});
/*
@ -1192,11 +1192,11 @@ public class ControlHandler {
if(!dragging && event.getButton1()){
dragging = true;
//fire dragstart event to elementmanager
Globals.elementManager.dragStart((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
Globals.elementService.dragStart((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
}
if(dragging){
//fire drag event to elementmanager
Globals.elementManager.drag((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
Globals.elementService.drag((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
}
}});
@ -1217,17 +1217,17 @@ public class ControlHandler {
//Decrementing a menu element
menuNavigationControlList.add(controls.get(DATA_STRING_INPUT_CODE_MENU_DECREMENT));
controls.get(DATA_STRING_INPUT_CODE_MENU_DECREMENT).setOnPress(new ControlMethod(){public void execute(){
Globals.elementManager.fireEvent(
Globals.elementService.fireEvent(
new MenuEvent(MenuEventType.DECREMENT),
Globals.elementManager.getFocusedElement().getAbsoluteX(),
Globals.elementManager.getFocusedElement().getAbsoluteY()
Globals.elementService.getFocusedElement().getAbsoluteX(),
Globals.elementService.getFocusedElement().getAbsoluteY()
);
}});
controls.get(DATA_STRING_INPUT_CODE_MENU_DECREMENT).setOnRepeat(new ControlMethod(){public void execute(){
Globals.elementManager.fireEvent(
Globals.elementService.fireEvent(
new MenuEvent(MenuEventType.DECREMENT),
Globals.elementManager.getFocusedElement().getAbsoluteX(),
Globals.elementManager.getFocusedElement().getAbsoluteY()
Globals.elementService.getFocusedElement().getAbsoluteX(),
Globals.elementService.getFocusedElement().getAbsoluteY()
);
}});
controls.get(DATA_STRING_INPUT_CODE_MENU_DECREMENT).setRepeatTimeout(0.5f * Main.targetFrameRate);
@ -1237,9 +1237,9 @@ public class ControlHandler {
menuNavigationControlList.add(controls.get(DATA_STRING_INPUT_CODE_MENU_SELECT));
controls.get(DATA_STRING_INPUT_CODE_MENU_SELECT).setOnPress(new ControlMethod(){public void execute(){
Globals.elementManager.click(new ClickEvent(
Globals.elementManager.getFocusedElement().getInternalX() + 1,
Globals.elementManager.getFocusedElement().getInternalY() + 1,
Globals.elementService.click(new ClickEvent(
Globals.elementService.getFocusedElement().getInternalX() + 1,
Globals.elementService.getFocusedElement().getInternalY() + 1,
true,
Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_2)
));
@ -1249,7 +1249,7 @@ public class ControlHandler {
menuNavigationControlList.add(controls.get(INPUT_CODE_MENU_MOUSE_PRIMARY));
mainGameDebugControlList.add(controls.get(INPUT_CODE_MENU_MOUSE_PRIMARY));
controls.get(INPUT_CODE_MENU_MOUSE_PRIMARY).setOnClick(new ControlMethod(){public void execute(){
Globals.elementManager.click(new ClickEvent(
Globals.elementService.click(new ClickEvent(
(int)xpos,
(int)ypos,
true,
@ -1265,7 +1265,7 @@ public class ControlHandler {
// }});
controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT).setOnClick(new ControlMethod(){public void execute(){
// MenuCallbacks.backout(Globals.currentMenu);
Globals.elementManager.navigateBackwards();
Globals.elementService.navigateBackwards();
// Globals.elementManager.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
}});
controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT).setRepeatTimeout(0.5f * Main.targetFrameRate);
@ -1396,9 +1396,9 @@ public class ControlHandler {
for(String currentKey : typeKeybinds){
typingControlList.add(controls.get(currentKey));
controls.get(currentKey).setOnPress(new ControlMethod(){public void execute(){
Globals.elementManager.fireEventNoPosition(
Globals.elementService.fireEventNoPosition(
new KeyboardEvent(convertKeycodeToName(controls.get(currentKey).keyValue)),
Globals.elementManager.getFocusedElement()
Globals.elementService.getFocusedElement()
);
// MenuCallbacks.menuHandleKeypress(Globals.currentMenu,currentKey);
}});
@ -1440,10 +1440,10 @@ public class ControlHandler {
if(dragging){
dragging = false;
//fire dragrelease event to elementmanager
Globals.elementManager.dragRelease((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
Globals.elementService.dragRelease((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
} else {
//fire onclick event to elementmanager
Globals.elementManager.click(new ClickEvent((int)xpos,(int)ypos,true,Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_2)));
Globals.elementService.click(new ClickEvent((int)xpos,(int)ypos,true,Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_2)));
}
}});
/*
@ -1454,11 +1454,11 @@ public class ControlHandler {
if(!dragging && event.getButton1()){
dragging = true;
//fire dragstart event to elementmanager
Globals.elementManager.dragStart((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
Globals.elementService.dragStart((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
}
if(dragging){
//fire drag event to elementmanager
Globals.elementManager.drag((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
Globals.elementService.drag((int)xpos,(int)ypos,(int)mouse_lastX,(int)mouse_lastY,(int)(xpos - mouse_lastX),(int)(mouse_lastY - ypos));
}
}});
}
@ -1568,7 +1568,7 @@ public class ControlHandler {
rVal = rVal || WindowUtils.windowIsOpen(windowString);
}
//check if any generated inventory windows are open
for(String windowId : Globals.elementManager.getCurrentWindowIds()){
for(String windowId : Globals.elementService.getCurrentWindowIds()){
rVal = rVal || (WindowUtils.windowIsOpen(windowId) && WindowUtils.isInventoryWindow(windowId));
}
//check imgui windows
@ -1582,10 +1582,10 @@ public class ControlHandler {
*/
private boolean onlyInventoryMenusOpen(){
boolean foundInventory = false;
for(String windowId : Globals.elementManager.getCurrentWindowIds()){
for(String windowId : Globals.elementService.getCurrentWindowIds()){
if(WindowUtils.isInventoryWindow(windowId) || WindowStrings.WINDOW_MENU_INVENTORY.equals(windowId) || WindowStrings.WINDOW_CHARACTER.equals(windowId)){
foundInventory = true;
} else if(Globals.elementManager.getWindow(windowId) instanceof Window == false || ((Window)Globals.elementManager.getWindow(windowId)).visible) {
} else if(Globals.elementService.getWindow(windowId) instanceof Window == false || ((Window)Globals.elementService.getWindow(windowId)).visible) {
return false;
}
}

View File

@ -361,7 +361,7 @@ public class Globals {
public static InitialAssetLoading initialAssetLoadingThread = new InitialAssetLoading();
//manager for all widgets currently being drawn to screen
public static ElementService elementManager;
public static ElementService elementService;
public static int openInventoriesCount = 0;
//collision world data
@ -493,7 +493,7 @@ public class Globals {
serviceManager.init();
//add services here
Globals.signalSystem = (SignalSystem)serviceManager.registerService(new SignalSystem());
Globals.elementManager = (ElementService)serviceManager.registerService(new ElementService());
Globals.elementService = (ElementService)serviceManager.registerService(new ElementService());
serviceManager.instantiate();
//
//End service manager
@ -501,7 +501,7 @@ public class Globals {
//
//Register all signals
Globals.signalSystem.registerService(SignalType.APPLY_YOGA, Globals.elementManager);
Globals.signalSystem.registerService(SignalType.APPLY_YOGA, Globals.elementService);
}

View File

@ -30,8 +30,8 @@ public class ClientLoading {
protected static void loadCharacterServer(Object[] params){
Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING);
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
Window loadingWindow = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_LOADING);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
loadingWindow.setVisible(true);
//disable menu input
@ -51,7 +51,7 @@ public class ClientLoading {
//make loading dialog disappear
loadingWindow.setVisible(false);
//make character creation window visible
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), true);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN), true);
//recapture window
Globals.controlHandler.setRecapture(true);
//log
@ -62,8 +62,8 @@ public class ClientLoading {
protected static void loadClientWorld(Object[] params){
Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING);
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
Window loadingWindow = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_LOADING);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
loadingWindow.setVisible(true);
//disable menu input

View File

@ -18,9 +18,9 @@ public class DebugSPWorldLoading {
protected static void loadDebugSPWorld(Object[] params){
Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING);
Window loadingWindow = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_LOADING);
//show loading
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
loadingWindow.setVisible(true);

View File

@ -53,9 +53,9 @@ public class LevelEditorLoading {
Globals.aiManager.setActive(false);
Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING);
Window loadingWindow = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_LOADING);
//show loading
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
loadingWindow.setVisible(true);

View File

@ -27,9 +27,9 @@ public class LevelLoading {
}
String saveName = (String)params[0];
Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING);
Window loadingWindow = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_LOADING);
//show loading
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN), false);
WindowUtils.replaceMainMenuContents(MenuGenerators.createEmptyMainMenu());
loadingWindow.setVisible(true);

View File

@ -65,12 +65,12 @@ public class MainMenuLoading {
* @param params Params (this thread type does not accept any)
*/
protected static void loadMainMenu(Object[] params){
Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING);
Window loadingWindow = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_LOADING);
if(loadingWindow != null){
WindowUtils.recursiveSetVisible(loadingWindow,false);
}
WindowUtils.focusWindow(WindowStrings.WINDOW_MENU_MAIN);
Window mainMenuWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN);
Window mainMenuWindow = (Window)Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN);
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
if(mainMenuWindow != null){
WindowUtils.recursiveSetVisible(mainMenuWindow, true);

View File

@ -23,14 +23,14 @@ public class WindowUtils {
* @param newMenu The new contents
*/
public static void replaceMainMenuContents(Element newMenu){
Element mainMenuEl = Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN);
Element mainMenuEl = Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_MAIN);
if(mainMenuEl != null && mainMenuEl instanceof Window){
Window mainMenu = (Window) mainMenuEl;
//todo: destroy elements as well
mainMenu.clear();
mainMenu.addChild(newMenu);
Globals.signalSystem.post(SignalType.APPLY_YOGA, mainMenu);
Globals.elementManager.focusFirstElement();
Globals.elementService.focusFirstElement();
}
}
@ -48,8 +48,8 @@ public class WindowUtils {
recursiveSetVisible(child, visible);
}
}
if(Globals.elementManager.getFocusedElement() == null){
Globals.elementManager.focusFirstElement();
if(Globals.elementService.getFocusedElement() == null){
Globals.elementService.focusFirstElement();
}
if(visible){
Globals.signalSystem.post(SignalType.APPLY_YOGA,topLevelMenu);
@ -62,8 +62,8 @@ public class WindowUtils {
* @return true if the window is open, false otherwise
*/
public static boolean windowIsOpen(String windowString){
Element windowElement = Globals.elementManager.getWindow(windowString);
return Globals.elementManager.getWindowList().contains(windowElement);
Element windowElement = Globals.elementService.getWindow(windowString);
return Globals.elementService.getWindowList().contains(windowElement);
}
/**
@ -84,34 +84,34 @@ public class WindowUtils {
}
public static void replaceWindowContents(String window, Element content){
Element mainMenuEl = Globals.elementManager.getWindow(window);
Element mainMenuEl = Globals.elementService.getWindow(window);
if(mainMenuEl != null && mainMenuEl instanceof Window){
Window mainMenu = (Window) mainMenuEl;
//todo: destroy elements as well
mainMenu.getChildren().clear();
mainMenu.addChild(content);
Globals.elementManager.focusFirstElement();
Globals.elementService.focusFirstElement();
}
}
public static void pushItemIconToItemWindow(Element itemIcon){
Window targetWindow = (Window) Globals.elementManager.getWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER);
Window targetWindow = (Window) Globals.elementService.getWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER);
targetWindow.addChild(itemIcon);
recursiveSetVisible(targetWindow,true);
Globals.elementManager.pushWindowToFront(targetWindow);
Globals.elementService.pushWindowToFront(targetWindow);
}
public static void cleanItemDraggingWindow(){
Window targetWindow = (Window) Globals.elementManager.getWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER);
Window targetWindow = (Window) Globals.elementService.getWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER);
targetWindow.getChildren().clear();
recursiveSetVisible(targetWindow, false);
}
public static void replaceWindow(String window, Window windowEl){
Globals.elementManager.unregisterWindow(window);
Globals.elementManager.registerWindow(window, windowEl);
Globals.elementService.unregisterWindow(window);
Globals.elementService.registerWindow(window, windowEl);
recursiveSetVisible(windowEl, true);
Globals.elementManager.focusFirstElement();
Globals.elementService.focusFirstElement();
}
/**
@ -119,9 +119,9 @@ public class WindowUtils {
* @param window the window to clean up
*/
public static void closeWindow(String window){
Element windowEl = Globals.elementManager.getWindow(window);
Element windowEl = Globals.elementService.getWindow(window);
recursiveSetVisible(windowEl, false);
Globals.elementManager.unregisterWindow(window);
Globals.elementService.unregisterWindow(window);
}
@ -133,7 +133,7 @@ public class WindowUtils {
//make sure we're client and the player entity exists
if(Globals.RUN_CLIENT && Globals.playerEntity != null){
//check equip inventory
if(InventoryUtils.hasEquipInventory(Globals.playerEntity) && Globals.elementManager.containsWindow(WindowStrings.WINDOW_CHARACTER)){
if(InventoryUtils.hasEquipInventory(Globals.playerEntity) && Globals.elementService.containsWindow(WindowStrings.WINDOW_CHARACTER)){
//redraw if necessary
RelationalInventoryState inventory = InventoryUtils.getEquipInventory(Globals.playerEntity);
WindowUtils.replaceWindow(WindowStrings.WINDOW_CHARACTER, MenuGeneratorsInventory.createCharacterInventoryMenu(inventory));
@ -142,7 +142,7 @@ public class WindowUtils {
if(InventoryUtils.hasNaturalInventory(Globals.playerEntity)){
//we need to know the inventory to know which window to check as there can be multiple unrelational inventory screens open
UnrelationalInventoryState inventory = InventoryUtils.getNaturalInventory(Globals.playerEntity);
if(Globals.elementManager.containsWindow(WindowUtils.getInventoryWindowID(inventory.getId()))){
if(Globals.elementService.containsWindow(WindowUtils.getInventoryWindowID(inventory.getId()))){
//once we have the natural inventory, redraw
WindowUtils.replaceWindow(WindowUtils.getInventoryWindowID(inventory.getId()), MenuGeneratorsInventory.createNaturalInventoryMenu(inventory));
}
@ -165,30 +165,30 @@ public class WindowUtils {
loadingLabel.setText("LOADING");
loadingWindow.addChild(loadingLabel);
Globals.signalSystem.post(SignalType.APPLY_YOGA,loadingWindow);
Globals.elementManager.registerWindow(WindowStrings.WINDOW_LOADING, loadingWindow);
Globals.elementService.registerWindow(WindowStrings.WINDOW_LOADING, loadingWindow);
WindowUtils.recursiveSetVisible(loadingWindow, true);
}
static void initMainMenuWindow(){
Window mainMenuWindow = new Window(Globals.renderingEngine.getOpenGLState(), 0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT,false);
Globals.elementManager.registerWindow(WindowStrings.WINDOW_MENU_MAIN, mainMenuWindow);
Globals.elementService.registerWindow(WindowStrings.WINDOW_MENU_MAIN, mainMenuWindow);
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
}
static void initItemDropWindow(){
Globals.elementManager.registerWindow(WindowStrings.WINDDOW_ITEM_DROP, MenuGeneratorsInventory.worldItemDropCaptureWindow());
Globals.elementService.registerWindow(WindowStrings.WINDDOW_ITEM_DROP, MenuGeneratorsInventory.worldItemDropCaptureWindow());
}
static void initItemDragContainerWindow(){
Window itemDragContainerWindow = new Window(Globals.renderingEngine.getOpenGLState(), 0,0,Globals.WINDOW_WIDTH,Globals.WINDOW_HEIGHT,false);
Globals.elementManager.registerWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER, itemDragContainerWindow);
Globals.elementService.registerWindow(WindowStrings.WINDOW_ITEM_DRAG_CONTAINER, itemDragContainerWindow);
}
public static void focusWindow(String window){
Element windowEl = Globals.elementManager.getWindow(window);
Element windowEl = Globals.elementService.getWindow(window);
if(windowEl != null){
Globals.elementManager.unregisterWindow(window);
Globals.elementManager.registerWindow(window, windowEl);
Globals.elementService.unregisterWindow(window);
Globals.elementService.registerWindow(window, windowEl);
}
}

View File

@ -52,8 +52,8 @@ public class MenuGeneratorsInGame {
Div div = Div.createDiv();
rVal.addChild(div);
div.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), false);
Globals.elementManager.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), false);
Globals.elementService.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
if(Globals.cameraHandler.getTrackPlayerEntity()){
Globals.controlHandler.hintUpdateControlState(ControlsState.MAIN_GAME);
} else {
@ -64,8 +64,8 @@ public class MenuGeneratorsInGame {
//Back
div.addChild(Button.createButton("Back", () -> {
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), false);
Globals.elementManager.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN), false);
Globals.elementService.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
if(Globals.cameraHandler.getTrackPlayerEntity()){
Globals.controlHandler.hintUpdateControlState(ControlsState.MAIN_GAME);
} else {

View File

@ -48,8 +48,8 @@ public class MenuGeneratorsInventory {
rVal.addChild(div);
rVal.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowUtils.getInventoryWindowID(inventory.getId())), false);
Globals.elementManager.unregisterWindow(WindowUtils.getInventoryWindowID(inventory.getId()));
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowUtils.getInventoryWindowID(inventory.getId())), false);
Globals.elementService.unregisterWindow(WindowUtils.getInventoryWindowID(inventory.getId()));
//
Globals.openInventoriesCount--;
if(Globals.openInventoriesCount == 0){
@ -160,7 +160,7 @@ public class MenuGeneratorsInventory {
container.removeChild(panel);
}
div.addChild(panel);
Globals.elementManager.fireEvent(event, event.getCurrentX(), event.getCurrentY());
Globals.elementService.fireEvent(event, event.getCurrentX(), event.getCurrentY());
}
panel.setPositionX(div.getAbsoluteX() + itemPosX);
panel.setPositionY(div.getAbsoluteY() + itemPosY);
@ -227,8 +227,8 @@ public class MenuGeneratorsInventory {
rVal.addChild(div);
rVal.setOnNavigationCallback(new NavigationEventCallback() {public boolean execute(NavigationEvent event){
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_CHARACTER), false);
Globals.elementManager.unregisterWindow(WindowStrings.WINDOW_CHARACTER);
WindowUtils.recursiveSetVisible(Globals.elementService.getWindow(WindowStrings.WINDOW_CHARACTER), false);
Globals.elementService.unregisterWindow(WindowStrings.WINDOW_CHARACTER);
//
Globals.openInventoriesCount--;
if(Globals.openInventoriesCount == 0){
@ -348,7 +348,7 @@ public class MenuGeneratorsInventory {
ContainerElement container = (ContainerElement)panel.getParent();
container.removeChild(panel);
}
Globals.elementManager.fireEvent(event, event.getCurrentX(), event.getCurrentY());
Globals.elementService.fireEvent(event, event.getCurrentX(), event.getCurrentY());
div.addChild(panel);
}
panel.setPositionX(div.getAbsoluteX() + itemPosX);

View File

@ -41,8 +41,8 @@ public class TutorialMenus {
//Get the window
Window windowEl;
if(Globals.elementManager.containsWindow(WindowStrings.TUTORIAL_POPUP)){
windowEl = (Window)Globals.elementManager.getWindow(WindowStrings.TUTORIAL_POPUP);
if(Globals.elementService.containsWindow(WindowStrings.TUTORIAL_POPUP)){
windowEl = (Window)Globals.elementService.getWindow(WindowStrings.TUTORIAL_POPUP);
} else {
//create the window
windowEl = new Window(Globals.renderingEngine.getOpenGLState(),0,0,TUTORIAL_POPUP_WIDTH,TUTORIAL_POPUP_HEIGHT,true);
@ -54,7 +54,7 @@ public class TutorialMenus {
windowEl.setFlexDirection(YogaFlexDirection.Column);
windowEl.setAlignItems(YogaAlignment.Center);
windowEl.setJustifyContent(YogaJustification.Between);
Globals.elementManager.registerWindow(WindowStrings.TUTORIAL_POPUP, windowEl);
Globals.elementService.registerWindow(WindowStrings.TUTORIAL_POPUP, windowEl);
}
//clear previous content

View File

@ -455,7 +455,7 @@ public class RenderingEngine {
public void drawScreen(){
//element manager handle outstanding signals
Globals.elementManager.handleAllSignals();
Globals.elementService.handleAllSignals();
//calculate render angle for frustum culling
if(Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT){

View File

@ -37,7 +37,7 @@ public class DebugRendering {
int parentPosX = 0;
int parentPosY = 0;
for(Element currentElement : Globals.elementManager.getWindowList()){
for(Element currentElement : Globals.elementService.getWindowList()){
if(currentElement instanceof DrawableElement){
DrawableElement drawable = (DrawableElement) currentElement;
if(drawable.getVisible()){
@ -130,7 +130,7 @@ public class DebugRendering {
}
public static void dumpUITree(){
for(Element currentElement : Globals.elementManager.getWindowList()){
for(Element currentElement : Globals.elementService.getWindowList()){
dumpUITree(currentElement, 1);
}
}

View File

@ -71,7 +71,7 @@ public class UIPipeline implements RenderPipeline {
openGLState.glDepthTest(false);
openGLState.glBlend(true);
for(Element currentElement : Globals.elementManager.getWindowList()){
for(Element currentElement : Globals.elementService.getWindowList()){
if(currentElement instanceof DrawableElement){
DrawableElement drawable = (DrawableElement) currentElement;
if(drawable.getVisible()){

View File

@ -120,7 +120,7 @@ public class ElementService extends SignalServiceImpl {
* @param windowString The window string
*/
public void closeWindow(String windowString){
Element windowEl = Globals.elementManager.getWindow(windowString);
Element windowEl = Globals.elementService.getWindow(windowString);
if(windowEl instanceof Window){
((Window)windowEl).handleEvent(new NavigationEvent(NavigationEventType.BACKWARD));
}

View File

@ -70,7 +70,7 @@ public class ScrollableContainer extends StandardContainerElement implements Dra
//recursively check if focused element is child of input element or is input element
boolean containsFocusedElement(Element parent){
Element focusedElement = Globals.elementManager.getFocusedElement();
Element focusedElement = Globals.elementService.getFocusedElement();
if(parent == focusedElement){
return true;
} else if(parent instanceof ContainerElement){
@ -97,7 +97,7 @@ public class ScrollableContainer extends StandardContainerElement implements Dra
//figure out if currently focused element is a child or subchild of this container
if(containsFocusedElement(this)){
//if it is, if it is offscreen, calculate offset to put it onscreen
Element focused = Globals.elementManager.getFocusedElement();
Element focused = Globals.elementService.getFocusedElement();
if(
focused.getRelativeX() + focused.getWidth() > this.width ||
focused.getRelativeY() + focused.getHeight() > this.height ||

View File

@ -232,7 +232,7 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
if(onClickCallback != null){
onClickCallback.execute(clickEvent);
} else {
Globals.elementManager.focusElement(this);
Globals.elementService.focusElement(this);
propagate = false;
}
} else if(event instanceof ValueChangeEvent){
@ -258,7 +258,7 @@ public class TextInput extends StandardContainerElement implements DrawableEleme
this.setText(this.text + keyEvent.getKey());
}
//fire value change event
Globals.elementManager.fireEventNoPosition(new ValueChangeEvent(text), this);
Globals.elementService.fireEventNoPosition(new ValueChangeEvent(text), this);
return false;
}

View File

@ -189,9 +189,9 @@ public class ToggleInput extends StandardDrawableElement implements ClickableEle
if(onClickCallback != null){
onClickCallback.execute(clickEvent);
} else {
Globals.elementManager.focusElement(this);
Globals.elementService.focusElement(this);
this.value = !this.value;
Globals.elementManager.fireEventNoPosition(new ValueChangeEvent(this.value), this);
Globals.elementService.fireEventNoPosition(new ValueChangeEvent(this.value), this);
propagate = false;
}
} else if(event instanceof ValueChangeEvent){