-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jm beta.25 : added infoslot event for adding infoslots
- Loading branch information
1 parent
6b188c0
commit 56b6778
Showing
4 changed files
with
195 additions
and
10 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
common/src/main/java/journeymap/api/v2/client/event/InfoSlotDisplayEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
common/src/main/java/journeymap/api/v2/common/event/FullscreenEventRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
||
} |
16 changes: 16 additions & 0 deletions
16
common/src/main/java/journeymap/api/v2/common/event/MinimapEventRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |