aktualizace mapview

main
Michal 2025-02-14 19:00:10 +01:00
parent 57371e1f26
commit e5cd72cb5f
3 changed files with 21 additions and 0 deletions

View File

@ -109,6 +109,7 @@ public class ClientMessageParser {
// aktualizace UI // aktualizace UI
UIUpdater.updateMapTree(); UIUpdater.updateMapTree();
UIUpdater.updateTray(); UIUpdater.updateTray();
break; break;
} }
} }
@ -154,6 +155,8 @@ public class ClientMessageParser {
for (Map map : Client.maps) { for (Map map : Client.maps) {
if (map.getId() == mo.getMap()) { if (map.getId() == mo.getMap()) {
map.getObjects().add(mo); map.getObjects().add(mo);
UIUpdater.updateMapView();
break;
} }
} }
} }

View File

@ -21,6 +21,8 @@ import jnet.lib.object.MapObject;
public class MapView extends JPanel { public class MapView extends JPanel {
public static List<PaintObject> paintObjects = new ArrayList<>(); public static List<PaintObject> paintObjects = new ArrayList<>();
private BufferedImage lockImage; private BufferedImage lockImage;
private BufferedImage unlockImage; private BufferedImage unlockImage;
@ -80,6 +82,15 @@ public class MapView extends JPanel {
} }
} }
public static void updateMapView() {
if (map.equals(MapView.map)) {
// obnoveni objektu
paintObjects.clear();
// nahrat objekty
loadObject(map.getId());
}
}
private static void loadObject(int mapId) { private static void loadObject(int mapId) {
for (Map map : Client.maps) { for (Map map : Client.maps) {
for (MapObject obj : map.getObjects()) { for (MapObject obj : map.getObjects()) {

View File

@ -1,6 +1,7 @@
package jnet.client.gui; package jnet.client.gui;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import jnet.lib.object.Map;
public class UIUpdater { public class UIUpdater {
@ -24,4 +25,10 @@ public class UIUpdater {
}); });
} }
public static void updateMapView() {
SwingUtilities.invokeLater(() -> {
MapView.updateMapView();
});
}
} }