Skip to content

Commit

Permalink
jm beta.25 : added infoslot event for adding infoslots
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticdrew committed Sep 6, 2024
1 parent 6b188c0 commit 56b6778
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package journeymap.api.v2.client.event;

import journeymap.api.v2.client.option.KeyedEnum;
import journeymap.api.v2.common.event.impl.ClientEvent;
import net.minecraft.network.chat.Component;

import java.util.LinkedHashMap;

public class InfoSlotDisplayEvent extends ClientEvent
{
private final LinkedHashMap<String, Position> infoSlotMap;

public InfoSlotDisplayEvent(LinkedHashMap<String, Position> infoSlotMap)
{
super(false);
this.infoSlotMap = infoSlotMap;
}

/**
* This will put it at the top, of either the top of minimap slots or bottoms of minimap slots.
*
* @param key - the key of the registered info slot.
* @param position - Position (top or bottom of minimap)
*/
public void addBefore(String key, Position position)
{
infoSlotMap.putFirst(key, position);
}

/**
* This will add a slot to the bottom, of either the bottom of minimap slots or bottom of minimap slots.
*
* @param key - the key of the registered info slot.
* @param position - Position (top or bottom of minimap)
*/
public void addLast(String key, Position position)
{
infoSlotMap.putLast(key, position);
}

/**
* Gets the map, remove, add, replace. Be careful!
*
* @return the map
*/
public LinkedHashMap<String, Position> getInfoSlotMap()
{
return infoSlotMap;
}

public enum Position implements KeyedEnum
{
Top("jm.minimap.info_slot.top"),
Bottom("jm.minimap.info_slot.bottom");

public final String key;

Position(String key)
{
this.key = key;
}

@Override
public String getKey()
{
return key;
}

@Override
public String toString()
{
return Component.translatable(this.key).getString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,52 @@ public class ClientEventRegistry
* Indicates that the fullscreen map is going to have a mouse click.
* This is a staged event. Pre can be canceled, post cannot be canceled.
* {@link FullscreenMapEvent.ClickEvent}, which can be cancelled.
*
* @deprecated use FullscreenEventRegistry
*/
@Deprecated(forRemoval = true) // use FullscreenEventRegistry
public static final Event<FullscreenMapEvent.ClickEvent> FULLSCREEN_MAP_CLICK_EVENT = EventFactory.create(FullscreenMapEvent.ClickEvent.class);

/**
* Indicates the start of the mouse dragging.
* This is a staged event. Pre can be canceled, post cannot be canceled.
* {@link FullscreenMapEvent.MouseDraggedEvent}, which can be cancelled.
*
* @deprecated use FullscreenEventRegistry
*/
@Deprecated(forRemoval = true) // use FullscreenEventRegistry
public static final Event<FullscreenMapEvent.MouseDraggedEvent> FULLSCREEN_MAP_DRAG_EVENT = EventFactory.create(FullscreenMapEvent.MouseDraggedEvent.class);

/**
* Indicates moving of the mouse, gets block info where the cursor is pointing.
* {@link FullscreenMapEvent.MouseMoveEvent}, which can not be cancelled.
*
* @deprecated use FullscreenEventRegistry
*/
@Deprecated(forRemoval = true) // use FullscreenEventRegistry
public static final Event<FullscreenMapEvent.MouseMoveEvent> FULLSCREEN_MAP_MOVE_EVENT = EventFactory.create(FullscreenMapEvent.MouseMoveEvent.class);
/**
* Register info slots.
* {@link RegistryEvent}
*
* @deprecated due to rename use {@link ClientEventRegistry#INFO_SLOT_REGISTRY_EVENT}
*/
@Deprecated(forRemoval = true)
public static final Event<RegistryEvent.InfoSlotRegistryEvent> INFO_SLOT_REGISTRY_EVENT_EVENT = EventFactory.create(RegistryEvent.InfoSlotRegistryEvent.class);

public static final Event<RegistryEvent.InfoSlotRegistryEvent> INFO_SLOT_REGISTRY_EVENT = INFO_SLOT_REGISTRY_EVENT_EVENT;
/**
* Register options in the addon options screen.
* {@link RegistryEvent}
*
* @deprecated due to rename use {@link ClientEventRegistry#OPTIONS_REGISTRY_EVENT}
*/
@Deprecated(forRemoval = true)
public static final Event<RegistryEvent.OptionsRegistryEvent> OPTIONS_REGISTRY_EVENT_EVENT = EventFactory.create(RegistryEvent.OptionsRegistryEvent.class);

public static final Event<RegistryEvent.OptionsRegistryEvent> OPTIONS_REGISTRY_EVENT = OPTIONS_REGISTRY_EVENT_EVENT;
/**
* This event handles all the CRUD operations of a waypoints.
* This event is not cancellable.
*
* @deprecated use {@link CommonEventRegistry#WAYPOINT_EVENT}
*/
@Deprecated(forRemoval = true)
Expand All @@ -92,24 +108,27 @@ public class ClientEventRegistry
* This event is fired when a user right clicks anywhere on the fullscreen map that is not an overlay or waypoint.
* To target overlays, see {@link IOverlayListener#onOverlayMenuPopup(UIState, Point2D.Double, BlockPos, ModPopupMenu)}
* This event is cancellable
*
* @deprecated use FullscreenEventRegistry
*/
@Deprecated(forRemoval = true) // use FullscreenEventRegistry
public static final Event<PopupMenuEvent.FullscreenPopupMenuEvent> FULLSCREEN_POPUP_MENU_EVENT = EventFactory.create(PopupMenuEvent.FullscreenPopupMenuEvent.class);

/**
* This event is fired when a user right-clicks on a waypoint icon.
* This event is cancellable.
*
* @deprecated use FullscreenEventRegistry
*/
@Deprecated(forRemoval = true) // use FullscreenEventRegistry
public static final Event<PopupMenuEvent.WaypointPopupMenuEvent> WAYPOINT_POPUP_MENU_EVENT = EventFactory.create(PopupMenuEvent.WaypointPopupMenuEvent.class);

/**
* Used to create custom toolbars on the fullscreen map.
*
* @deprecated this event should be a rare usage event, most mods should use {@link FullscreenDisplayEvent.AddonButtonDisplayEvent}.
* Overuse of this event can cause toolbars to display over other mod's toolbars.
* USE SPARINGLY!
* This event is not cancellable
* @deprecated use FullscreenEventRegistry
*/
@Deprecated
@Deprecated(forRemoval = true) // use FullscreenEventRegistry
public static final Event<FullscreenDisplayEvent.CustomToolbarEvent> CUSTOM_TOOLBAR_UPDATE_EVENT = EventFactory.create(FullscreenDisplayEvent.CustomToolbarEvent.class);

/**
Expand All @@ -118,16 +137,18 @@ public class ClientEventRegistry
* those that want to add maptypes through your own means.
* This event is not cancellable
*
* @deprecated since this is a special event that requires special modification to use,
* it is suggested to not use it without first discussing with TeamJM developers.
* @deprecated use FullscreenEventRegistry
*/
@Deprecated
@Deprecated(forRemoval = true) // use FullscreenEventRegistry
public static final Event<FullscreenDisplayEvent.MapTypeButtonDisplayEvent> MAP_TYPE_BUTTON_DISPLAY_EVENT = EventFactory.create(FullscreenDisplayEvent.MapTypeButtonDisplayEvent.class);

/**
* This event is used for adding buttons to the right panel on the fullscreen map.
* This event is not cancellable.
*
* @deprecated use FullscreenEventRegistry
*/
@Deprecated(forRemoval = true) // use FullscreenEventRegistry
public static final Event<FullscreenDisplayEvent.AddonButtonDisplayEvent> ADDON_BUTTON_DISPLAY_EVENT = EventFactory.create(FullscreenDisplayEvent.AddonButtonDisplayEvent.class);

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package journeymap.api.v2.common.event;

import journeymap.api.v2.client.display.IOverlayListener;
import journeymap.api.v2.client.event.FullscreenDisplayEvent;
import journeymap.api.v2.client.event.FullscreenMapEvent;
import journeymap.api.v2.client.event.PopupMenuEvent;
import journeymap.api.v2.client.fullscreen.ModPopupMenu;
import journeymap.api.v2.client.util.UIState;
import journeymap.api.v2.common.event.impl.Event;
import net.minecraft.core.BlockPos;

import java.awt.geom.Point2D;

public class FullscreenEventRegistry
{
/**
* Indicates that the fullscreen map is going to have a mouse click.
* This is a staged event. Pre can be canceled, post cannot be canceled.
* {@link FullscreenMapEvent.ClickEvent}, which can be cancelled.
*/
public static final Event<FullscreenMapEvent.ClickEvent> FULLSCREEN_MAP_CLICK_EVENT = ClientEventRegistry.FULLSCREEN_MAP_CLICK_EVENT;

/**
* Indicates the start of the mouse dragging.
* This is a staged event. Pre can be canceled, post cannot be canceled.
* {@link FullscreenMapEvent.MouseDraggedEvent}, which can be cancelled.
*/
public static final Event<FullscreenMapEvent.MouseDraggedEvent> FULLSCREEN_MAP_DRAG_EVENT = ClientEventRegistry.FULLSCREEN_MAP_DRAG_EVENT;

/**
* Indicates moving of the mouse, gets block info where the cursor is pointing.
* {@link FullscreenMapEvent.MouseMoveEvent}, which can not be cancelled.
*/
public static final Event<FullscreenMapEvent.MouseMoveEvent> FULLSCREEN_MAP_MOVE_EVENT = ClientEventRegistry.FULLSCREEN_MAP_MOVE_EVENT;

/**
* This event is fired when a user right clicks anywhere on the fullscreen map that is not an overlay or waypoint.
* To target overlays, see {@link IOverlayListener#onOverlayMenuPopup(UIState, Point2D.Double, BlockPos, ModPopupMenu)}
* This event is cancellable
*/
public static final Event<PopupMenuEvent.FullscreenPopupMenuEvent> FULLSCREEN_POPUP_MENU_EVENT = ClientEventRegistry.FULLSCREEN_POPUP_MENU_EVENT;

/**
* This event is fired when a user right-clicks on a waypoint icon.
* This event is cancellable.
*/
public static final Event<PopupMenuEvent.WaypointPopupMenuEvent> WAYPOINT_POPUP_MENU_EVENT = ClientEventRegistry.WAYPOINT_POPUP_MENU_EVENT;

/**
* Used to create custom toolbars on the fullscreen map.
*/
public static final Event<FullscreenDisplayEvent.CustomToolbarEvent> CUSTOM_TOOLBAR_UPDATE_EVENT = ClientEventRegistry.CUSTOM_TOOLBAR_UPDATE_EVENT;

/**
* Used for adding buttons to the maptype theme button list.
* We currently do not have any hooks to add map types, but this event exists for
* those that want to add maptypes through your own means.
* This event is not cancellable
*
* @deprecated since this is a special event that requires special modification to use,
* it is suggested to not use it without first discussing with TeamJM developers.
*/
@Deprecated()
public static final Event<FullscreenDisplayEvent.MapTypeButtonDisplayEvent> MAP_TYPE_BUTTON_DISPLAY_EVENT = ClientEventRegistry.MAP_TYPE_BUTTON_DISPLAY_EVENT;

/**
* This event is used for adding buttons to the right panel on the fullscreen map.
* This event is not cancellable.
*/
public static final Event<FullscreenDisplayEvent.AddonButtonDisplayEvent> ADDON_BUTTON_DISPLAY_EVENT = ClientEventRegistry.ADDON_BUTTON_DISPLAY_EVENT;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package journeymap.api.v2.common.event;

import journeymap.api.v2.client.event.InfoSlotDisplayEvent;
import journeymap.api.v2.common.event.impl.Event;
import journeymap.api.v2.common.event.impl.EventFactory;

public class MinimapEventRegistry
{

/**
* This event allows addons to add, update, remove, replace current info slots. It will allow to force display your own slot anywhere in the displayed lists.
* Four info slots not enough? This event can add unlimited slots!
*/
public static final Event<InfoSlotDisplayEvent> INFO_SLOT_DISPLAY_EVENT = EventFactory.create(InfoSlotDisplayEvent.class);

}

0 comments on commit 56b6778

Please sign in to comment.