Skip to content

Commit 86d0719

Browse files
Merge pull request #5824 from Baaaaaz/feature/5786-token-halos-in-campaign-properties
New Custom Halos
2 parents 15b19b6 + 1c6087d commit 86d0719

35 files changed

+4398
-567
lines changed

messages/src/main/proto/data_transfer_objects.proto

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,58 @@ message LightDto {
100100
int32 lumens = 9;
101101
}
102102

103+
message HaloDto {
104+
string id = 1;
105+
string name = 2;
106+
bool gm_only = 3;
107+
bool owner_only = 4;
108+
bool inner = 5;
109+
bool facing_with_token = 6;
110+
bool flip_with_token = 7;
111+
bool scale_with_token = 8;
112+
repeated HaloPartDto halo_parts = 9;
113+
}
114+
115+
message HaloPartDto {
116+
enum HaloShapeTypeDto {
117+
CIRCLE = 0;
118+
ARC = 1;
119+
CHORD = 2;
120+
PIE = 3;
121+
TRIANGLE = 4;
122+
SQUARE = 5;
123+
POLYGON = 6;
124+
STAR = 7;
125+
GRID = 8;
126+
FOOTPRINT = 9;
127+
TOKEN = 10;
128+
OUTLINE = 11;
129+
MBL = 12;
130+
VBLCOVER = 13;
131+
VBLHILL = 14;
132+
VBLPIT = 15;
133+
VBLWALL = 16;
134+
}
135+
DrawablePaintDto paint = 1;
136+
HaloShapeTypeDto halo_shape_type = 2;
137+
google.protobuf.Int32Value width = 3;
138+
repeated float dashed_pattern = 4;
139+
bool fill = 5;
140+
bool flip_horizontal = 6;
141+
bool flip_vertical = 7;
142+
double angle = 8;
143+
double offset = 9;
144+
double rotate = 10;
145+
double scale_x = 11;
146+
double scale_y = 12;
147+
int32 vertices = 13;
148+
int32 mini = 14;
149+
int32 mini_start = 15;
150+
int32 mini_stop = 16;
151+
double mini_rotate = 17;
152+
double mini_spin = 18;
153+
}
154+
103155
message LocationDto {
104156
oneof LocationTyp {
105157
LocalLocationDto local_location = 1;
@@ -134,6 +186,7 @@ message CampaignPropertiesDto {
134186
repeated SightTypeDto sight_types = 13;
135187
map<string, StatSheetPropertiesDto> token_type_stat_sheet = 14;
136188
google.protobuf.StringValue default_token_property_type = 15;
189+
map<string, HaloListDto> halos = 16;
137190
}
138191

139192
message SightTypeDto {
@@ -289,6 +342,10 @@ message LightSourceListDto {
289342
repeated LightSourceDto light_sources = 1;
290343
}
291344

345+
message HaloListDto {
346+
repeated HaloDto halos = 1;
347+
}
348+
292349
enum WalkerMetricDto {
293350
NO_DIAGONALS = 0;
294351
MANHATTAN = 1;
@@ -403,6 +460,7 @@ message TokenDto {
403460
string notes_type = 68;
404461
string gm_notes_type = 69;
405462
StatSheetPropertiesDto stat_sheet_properties = 70;
463+
repeated string halo_guids = 73;
406464
}
407465

408466
message PathDto {
@@ -695,6 +753,9 @@ enum TokenUpdateDto {
695753
flipIso = 55;
696754
setSpeechName = 56;
697755
removeFacing = 57;
756+
clearHalos = 58;
757+
removeHalo = 59;
758+
addHalo = 60;
698759
}
699760

700761
message AssetTransferHeaderDto {
@@ -722,6 +783,8 @@ message TokenPropertyValueDto {
722783
GridDto grid = 10;
723784
TokenFootPrintDto token_foot_print = 11;
724785
string topology_type = 12;
786+
string halo_id = 13;
787+
HaloDto halo = 14;
725788
}
726789
}
727790

src/main/java/net/rptools/maptool/client/AppActions.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,13 +1623,39 @@ protected void executeAction(@Nonnull ZoneRenderer renderer) {
16231623
}
16241624
}
16251625

1626+
public static final Action TOGGLE_SHOW_TOKEN_HALOS =
1627+
new TranslatedClientAction(
1628+
"action.showTokenHalos", withMenuShortcut(KeyStroke.getKeyStroke("Q"))) {
1629+
{
1630+
putValue(Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_SHOW_TOKEN_HALOS));
1631+
}
1632+
1633+
@Override
1634+
public boolean isSelected() {
1635+
return AppState.isShowTokenHalos();
1636+
}
1637+
1638+
@Override
1639+
protected void executeAction() {
1640+
AppState.setShowTokenHalos(!AppState.isShowTokenHalos());
1641+
if (MapTool.getFrame().getCurrentZoneRenderer() != null) {
1642+
MapTool.getFrame().getCurrentZoneRenderer().repaint();
1643+
}
1644+
}
1645+
};
1646+
16261647
public static final Action TOGGLE_SHOW_TOKEN_NAMES =
16271648
new TranslatedClientAction(
16281649
"action.showNames", withMenuShortcut(KeyStroke.getKeyStroke("T"))) {
16291650
{
16301651
putValue(Action.SMALL_ICON, RessourceManager.getSmallIcon(Icons.MENU_SHOW_TOKEN_NAMES));
16311652
}
16321653

1654+
@Override
1655+
public boolean isSelected() {
1656+
return AppState.isShowTokenNames();
1657+
}
1658+
16331659
@Override
16341660
protected void executeAction() {
16351661

src/main/java/net/rptools/maptool/client/AppState.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class AppState {
2828

2929
private static boolean showGrid = false;
3030
private static boolean showCoordinates = false;
31+
private static boolean showTokenHalos = true;
3132
private static boolean showTokenNames = false;
3233
private static boolean linkPlayerViews = false;
3334
private static boolean useDoubleWideLine = true;
@@ -123,6 +124,14 @@ public static void setShowCoordinates(boolean flag) {
123124
showCoordinates = flag;
124125
}
125126

127+
public static void setShowTokenHalos(boolean flag) {
128+
showTokenHalos = flag;
129+
}
130+
131+
public static boolean isShowTokenHalos() {
132+
return showTokenHalos;
133+
}
134+
126135
public static void setShowTokenNames(boolean flag) {
127136
showTokenNames = flag;
128137
}

src/main/java/net/rptools/maptool/client/MapToolExpressionParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class MapToolExpressionParser extends ExpressionParser {
7070
TokenBarFunction.getInstance(),
7171
TokenCopyDeleteFunctions.getInstance(),
7272
TokenGMNameFunction.getInstance(),
73-
TokenHaloFunction.getInstance(),
73+
TokenHaloFunctions.getInstance(),
7474
TokenImage.getInstance(),
7575
TokenInitFunction.getInstance(),
7676
TokenInitHoldFunction.getInstance(),

src/main/java/net/rptools/maptool/client/MapToolVariableResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public Object getVariable(String name, VariableModifiers mods) throws ParserExce
215215
// We don't want this evaluated as the # format is more useful to us then the
216216
// evaluated
217217
// format.
218-
return TokenHaloFunction.getHalo(tokenInContext).toString();
218+
return TokenHaloFunctions.getHalo(tokenInContext).toString();
219219
} else if (name.equals(TOKEN_NAME)) {
220220
// Don't evaluate return value.
221221
return TokenNameFunction.getName(tokenInContext);
@@ -370,7 +370,7 @@ public void setVariable(String varname, VariableModifiers modifiers, Object valu
370370
TokenBarFunction.setValue(tokenInContext, barName, value);
371371
return;
372372
} else if (varname.equals(TOKEN_HALO)) {
373-
TokenHaloFunction.setHalo(tokenInContext, value);
373+
TokenHaloFunctions.setHalo(tokenInContext, value);
374374
return;
375375
} else if (varname.equals(TOKEN_NAME)) {
376376
if (value.toString().equals("")) {

src/main/java/net/rptools/maptool/client/ServerCommandClientImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,16 @@ public void toggleLightSourceOnToken(Token token, boolean toggleOn, LightSource
672672
.build());
673673
}
674674

675+
@Override
676+
public void toggleHaloSourceOnToken(Token token, boolean toggleOn, Halo halo) {
677+
var update = toggleOn ? Token.Update.addHalo : Token.Update.removeHalo;
678+
// We only need to send the ID of the halo source.
679+
updateTokenProperty(
680+
token,
681+
update,
682+
TokenPropertyValueDto.newBuilder().setHaloId(halo.getId().toString()).build());
683+
}
684+
675685
public void setTokenMaskTopology(
676686
Token token, @Nullable Area area, Zone.TopologyType topologyType) {
677687
if (area == null) {

src/main/java/net/rptools/maptool/client/functions/TokenHaloFunction.java

Lines changed: 0 additions & 181 deletions
This file was deleted.

0 commit comments

Comments
 (0)