Skip to content

Commit 762c1fe

Browse files
committed
Merge branch 'main' into randomDate
2 parents 47de884 + 02b0016 commit 762c1fe

File tree

13 files changed

+826
-11
lines changed

13 files changed

+826
-11
lines changed

megamek/resources/megamek/client/messages.properties

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,11 @@ MekSelectorDialog.Search.Engine=Engine Type:
23062306
MekSelectorDialog.Search.Gyro=Gyro Type:
23072307
MekSelectorDialog.Search.ClanEngine=Clan Engine:
23082308
MekSelectorDialog.Search.Source=Source:
2309-
MekSelectorDialog.Search.Source.TT=Multiple search tokens can be used, separated by spaces, e.g. "guide #9"
2309+
MekSelectorDialog.Search.Source.TT=<html>Enter search token(s). Note:<br>- Use the short name of sources, such as \
2310+
TR:3039 or Shrap09; the full names are not available for searching<br>- Choose a \
2311+
source from the menu to add its short name to the search field<br>- Multiple search tokens can be used, separated \
2312+
by spaces, e.g. "shr 9"
2313+
MekSelectorDialog.Search.Source.selectSource=Select a source
23102314
MekSelectorDialog.Search.MULId=MUL Id:
23112315
MekSelectorDialog.Search.TroopSpace=Infantry Compartments:
23122316
MekSelectorDialog.Search.ASFBays=ASF Bays:
@@ -5000,3 +5004,9 @@ ForceDisplay.Button.ECM=ECM
50005004
ForceDisplay.Button.Quirks=Quirks
50015005
ForceDisplay.Button.C3=C3
50025006
ForceDisplay.Button.Misc=Misc.
5007+
5008+
# Source Chooser Dialog
5009+
SourceChooser.title=Choose Source
5010+
SourceChooser.list=Choose From List:
5011+
SourceChooser.manual=Enter Manual Value:
5012+
SourceChooser.or=OR

megamek/resources/megamek/client/messages_de.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,3 +1248,9 @@ CASCardPanel.cardSize=Kartengr\uFFFD\uFFFDe:
12481248
Error=Fehler
12491249
BoardEditor.loadBoardError=Karte konnte nicht geladen werden.
12501250
WeaponAttackAction.ArtyOutOfWater=Artillerie-Waffen au\uFFFDer Cruise Missiles k\uFFFDnnen nicht von unterhalb der Wasseroberfl\uFFFDche abgefeuert werden.
1251+
SourceChooser.title=Quelle festlegen
1252+
SourceChooser.list=Quellenauswahl:
1253+
SourceChooser.manual=Manuelle Eingabe:
1254+
SourceChooser.or=ODER
1255+
MekSelectorDialog.Search.Source.TT=<html>Gib einen oder mehrere Suchbegriffe ein. Beachte:<br>- Verwende die Kurzname für die Bücher wie \
1256+
TR:3039 oder Shrap09; die vollständigen Titel werden in der Suche nicht verwendet<br>- Ein Buch kann aus dem Menü ausgewählt werden, der Kurzname wird dann im Suchfeld zugefügt<br>- Mehrere Suchbegriffe können durch Leerzeichen getrennt verwendet werden, z.B. "shr 9"

megamek/resources/megamek/client/messages_es.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4161,3 +4161,4 @@ ForceGeneratorDialog.default=Predeterminado
41614161
ForceGeneratorDialog.noCrew=Sin tripulaci\u00F3n
41624162
Gamemaster.Traitor=Unidad Traidora
41634163
TipOfTheDay.title.text=Consejo r\u00E1pido:
4164+
SourceChooser.or=O
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright (C) 2025 The MegaMek Team. All Rights Reserved.
3+
*
4+
* This file is part of MegaMek.
5+
*
6+
* MegaMek is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License (GPL),
8+
* version 3 or (at your option) any later version,
9+
* as published by the Free Software Foundation.
10+
*
11+
* MegaMek is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty
13+
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14+
* See the GNU General Public License for more details.
15+
*
16+
* A copy of the GPL should have been included with this project;
17+
* if not, see <https://www.gnu.org/licenses/>.
18+
*
19+
* NOTICE: The MegaMek organization is a non-profit group of volunteers
20+
* creating free software for the BattleTech community.
21+
*
22+
* MechWarrior, BattleMech, `Mech and AeroTech are registered trademarks
23+
* of The Topps Company, Inc. All Rights Reserved.
24+
*
25+
* Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of
26+
* InMediaRes Productions, LLC.
27+
*
28+
* MechWarrior Copyright Microsoft Corporation. MegaMek was created under
29+
* Microsoft's "Game Content Usage Rules"
30+
* <https://www.xbox.com/en-US/developers/rules> and it is not endorsed by or
31+
* affiliated with Microsoft.
32+
*/
33+
package megamek.client.ui.baseComponents;
34+
35+
import com.formdev.flatlaf.icons.FlatAbstractIcon;
36+
37+
import javax.swing.*;
38+
import java.awt.*;
39+
import java.awt.geom.*;
40+
41+
/**
42+
* An icon showing stylized books and a mouse arrow. Used for sourcebook selection.
43+
*/
44+
public class BooksIcon extends FlatAbstractIcon {
45+
private final int size;
46+
47+
/**
48+
* Creates a books icon at the standard size (16) suitable to place it in line with, e.g. a JTextfield and with a
49+
* standard FlatLaf color.
50+
*/
51+
public BooksIcon() {
52+
this(16);
53+
}
54+
55+
/**
56+
* Creates a books icon of the given size and with a standard FlatLaf color.
57+
*/
58+
public BooksIcon(int size) {
59+
super(size, size, UIManager.getColor("Actions.Grey"));
60+
this.size = size;
61+
}
62+
63+
@Override
64+
public void paintIcon(Component c, Graphics2D g) {
65+
double baseY = size;
66+
double x = size * 0.05;
67+
double baseHeight = size;
68+
double height1 = baseHeight * 0.7;
69+
double height2 = baseHeight * 0.9;
70+
double height3 = baseHeight * 0.83;
71+
double baseThickness = size * 0.14;
72+
double thickness1 = baseThickness * 1.1;
73+
double thickness2 = baseThickness * 1.4;
74+
double thickness3 = baseThickness * 0.9;
75+
double distance = size * 0.1;
76+
Area booksArea = new Area();
77+
booksArea.add(new Area(new RoundRectangle2D.Double(x, baseY - height1, thickness1, height1, 1, 1)));
78+
x += thickness1 + distance;
79+
booksArea.add(new Area(new RoundRectangle2D.Double(x, baseY - height2, thickness2, height2, 1, 1)));
80+
x += thickness2 + distance;
81+
booksArea.add(new Area(new RoundRectangle2D.Double(x, baseY - height3, thickness3, height3, 1, 1)));
82+
83+
// Arrow
84+
Path2D.Double path = new Path2D.Double();
85+
double h = size * 0.5;
86+
double q = size * 0.2;
87+
double tipX = size * 0.75;
88+
double tipY = size * 0.75;
89+
double a = (h * h - q * q) / (2 * h);
90+
path.moveTo(0, a - h);
91+
path.lineTo(-q, a);
92+
path.lineTo(q, a);
93+
path.closePath();
94+
95+
double arrowScale = 1;
96+
double outlineScale = arrowScale * 1.8;
97+
double angle = -38;
98+
99+
Area arrowOutline = new Area(path);
100+
arrowOutline.transform(AffineTransform.getScaleInstance(outlineScale, outlineScale));
101+
arrowOutline.transform(AffineTransform.getRotateInstance(Math.toRadians(angle)));
102+
arrowOutline.transform(AffineTransform.getTranslateInstance(tipX, tipY));
103+
104+
Area arrowArea = new Area(path);
105+
arrowArea.transform(AffineTransform.getScaleInstance(arrowScale, arrowScale));
106+
arrowArea.transform(AffineTransform.getRotateInstance(Math.toRadians(angle)));
107+
arrowArea.transform(AffineTransform.getTranslateInstance(tipX, tipY));
108+
109+
booksArea.subtract(arrowOutline);
110+
booksArea.add(arrowArea);
111+
Graphics2D g2d = (Graphics2D) g.create();
112+
g2d.setClip(0, 0, size, size);
113+
g2d.fill(booksArea);
114+
g2d.dispose();
115+
}
116+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Copyright (C) 2025 The MegaMek Team. All Rights Reserved.
3+
*
4+
* This file is part of MegaMek.
5+
*
6+
* MegaMek is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License (GPL),
8+
* version 3 or (at your option) any later version,
9+
* as published by the Free Software Foundation.
10+
*
11+
* MegaMek is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty
13+
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14+
* See the GNU General Public License for more details.
15+
*
16+
* A copy of the GPL should have been included with this project;
17+
* if not, see <https://www.gnu.org/licenses/>.
18+
*
19+
* NOTICE: The MegaMek organization is a non-profit group of volunteers
20+
* creating free software for the BattleTech community.
21+
*
22+
* MechWarrior, BattleMech, `Mech and AeroTech are registered trademarks
23+
* of The Topps Company, Inc. All Rights Reserved.
24+
*
25+
* Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of
26+
* InMediaRes Productions, LLC.
27+
*
28+
* MechWarrior Copyright Microsoft Corporation. MegaMek was created under
29+
* Microsoft's "Game Content Usage Rules"
30+
* <https://www.xbox.com/en-US/developers/rules> and it is not endorsed by or
31+
* affiliated with Microsoft.
32+
*/
33+
package megamek.client.ui.baseComponents;
34+
35+
import com.formdev.flatlaf.icons.FlatAbstractIcon;
36+
37+
import javax.swing.UIManager;
38+
import java.awt.Component;
39+
import java.awt.Graphics2D;
40+
import java.awt.Shape;
41+
import java.awt.geom.AffineTransform;
42+
import java.awt.geom.Area;
43+
import java.awt.geom.Ellipse2D;
44+
import java.awt.geom.Rectangle2D;
45+
import java.awt.geom.RoundRectangle2D;
46+
47+
/**
48+
* This is a cogwheel icon that usually indicates some sort of config menu.
49+
*/
50+
public class CogwheelIcon extends FlatAbstractIcon {
51+
52+
private final int size;
53+
private final int radius;
54+
private final int teeth;
55+
private final int toothDepth;
56+
private final int holeRadius;
57+
private Shape shape;
58+
59+
/**
60+
* Creates a cogwheel icon at the standard size (16) suitable to place it in line with, e.g. a JTextfield and with a
61+
* standard FlatLaf color.
62+
*/
63+
public CogwheelIcon() {
64+
this(16);
65+
}
66+
67+
/**
68+
* Creates a cogwheel icon of the given size and with a standard FlatLaf color.
69+
*/
70+
public CogwheelIcon(int size) {
71+
this(size, size * 6 / 16, 6, size * 2 / 16, size * 3 / 16);
72+
}
73+
74+
/**
75+
* Creates a configurable cogwheel icon at given size and with the given values.
76+
*/
77+
public CogwheelIcon(int size, int radius, int teeth, int toothDepth, int holeRadius) {
78+
super(size, size, UIManager.getColor("Actions.Grey"));
79+
this.size = size;
80+
this.radius = radius;
81+
this.teeth = teeth;
82+
this.toothDepth = toothDepth;
83+
this.holeRadius = holeRadius;
84+
}
85+
86+
@Override
87+
protected void paintIcon(Component c, Graphics2D g) {
88+
if (shape == null) {
89+
shape = createCogwheel(size / 2, size / 2, radius, teeth, toothDepth, holeRadius);
90+
}
91+
g.fill(shape);
92+
}
93+
94+
private Shape createCog(int cx, int cy, int radius, int teeth, int toothDepth) {
95+
double angleStep = 2 * Math.PI / teeth;
96+
double toothWidthAngle = angleStep * 0.6; // fraction of arc used by tooth
97+
double dx = Math.sin(toothWidthAngle / 2) * radius;
98+
double Y1 = cy - radius * Math.cos(toothWidthAngle / 2);
99+
Area cog = new Area(new RoundRectangle2D.Double(cx - dx, Y1 - toothDepth, 2 * dx,
100+
toothDepth * 0.5, toothDepth, toothDepth));
101+
cog.add(new Area(new Rectangle2D.Double(cx - dx, Y1 - toothDepth * 0.75, 2 * dx, toothDepth)));
102+
return cog;
103+
}
104+
105+
private Shape createCogwheel(int cx, int cy, int radius, int teeth,
106+
int toothDepth, int holeRadius) {
107+
double angleStep = 2 * Math.PI / teeth;
108+
Area cogArea = new Area();
109+
Shape wheel = new Ellipse2D.Double(cx - radius, cy - radius, 2 * radius, 2 * radius);
110+
Shape hole = new Ellipse2D.Double(cx - holeRadius, cy - holeRadius, 2 * holeRadius, 2 * holeRadius);
111+
cogArea.add(new Area(wheel));
112+
cogArea.subtract(new Area(hole));
113+
114+
Shape baseCog = createCog(cx, cy, radius, teeth, toothDepth);
115+
var rotateTransform = new AffineTransform();
116+
for (int i = 0; i < teeth; i++) {
117+
Shape rotatedCog = rotateTransform.createTransformedShape(baseCog);
118+
cogArea.add(new Area(rotatedCog));
119+
rotateTransform.rotate(angleStep, cx, cy);
120+
}
121+
122+
return cogArea;
123+
}
124+
}
125+
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright (C) 2025 The MegaMek Team. All Rights Reserved.
3+
*
4+
* This file is part of MegaMek.
5+
*
6+
* MegaMek is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License (GPL),
8+
* version 3 or (at your option) any later version,
9+
* as published by the Free Software Foundation.
10+
*
11+
* MegaMek is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty
13+
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14+
* See the GNU General Public License for more details.
15+
*
16+
* A copy of the GPL should have been included with this project;
17+
* if not, see <https://www.gnu.org/licenses/>.
18+
*
19+
* NOTICE: The MegaMek organization is a non-profit group of volunteers
20+
* creating free software for the BattleTech community.
21+
*
22+
* MechWarrior, BattleMech, `Mech and AeroTech are registered trademarks
23+
* of The Topps Company, Inc. All Rights Reserved.
24+
*
25+
* Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of
26+
* InMediaRes Productions, LLC.
27+
*
28+
* MechWarrior Copyright Microsoft Corporation. MegaMek was created under
29+
* Microsoft's "Game Content Usage Rules"
30+
* <https://www.xbox.com/en-US/developers/rules> and it is not endorsed by or
31+
* affiliated with Microsoft.
32+
*/
33+
package megamek.client.ui.baseComponents;
34+
35+
import com.formdev.flatlaf.icons.FlatAbstractIcon;
36+
import megamek.client.ui.util.StringDrawer;
37+
38+
import javax.swing.*;
39+
import java.awt.*;
40+
import java.awt.geom.*;
41+
42+
/**
43+
* A link icon (two chain links) and the letters "MUL". Clicking it opens the supplied URL
44+
* in the system browser (if supported).
45+
*/
46+
public class MulLinkIcon extends FlatAbstractIcon {
47+
48+
private final int size; // total square size of the icon (pixels)
49+
50+
/**
51+
* Creates a MUL link icon at the standard size (16) suitable to place it in line with, e.g. a JTextfield and a
52+
* standard FlatLaf color.
53+
*/
54+
public MulLinkIcon() {
55+
this(16);
56+
}
57+
58+
/**
59+
* Creates a MUL link icon with the given size and the standard FlatLaf color.
60+
*
61+
* @param size The pixel size of the icon. Note that this is automatically scaled depending on the GUI scaling
62+
*/
63+
public MulLinkIcon(int size) {
64+
this(size, UIManager.getColor("Actions.Grey"));
65+
}
66+
67+
/**
68+
* Creates a MUL link icon with the given size and given color.
69+
*
70+
* @param size The pixel size of the icon. Note that this is automatically scaled depending on the GUI scaling
71+
* @param color The color to use for drawing the icon's shape
72+
*/
73+
public MulLinkIcon(int size, Color color) {
74+
super(size, size, color);
75+
this.size = size;
76+
}
77+
78+
@Override
79+
protected void paintIcon(Component c, Graphics2D g) {
80+
double length = size * 0.5;
81+
double width = length * 0.6;
82+
double thickness = width * 0.2;
83+
84+
AffineTransform translateLink1 = AffineTransform.getTranslateInstance((size - length) * 0.5,
85+
size * 0.27 - width / 2);
86+
translateLink1.translate(size * 0.15, size * 0.03);
87+
AffineTransform translateLink2 = AffineTransform.getTranslateInstance((size - length) * 0.5,
88+
size * 0.27 - width / 2);
89+
translateLink2.translate(-size * 0.15, -size * 0.03);
90+
91+
g.fill(translateLink1.createTransformedShape(createLink(length, width, thickness)));
92+
g.fill(translateLink2.createTransformedShape(createLink(length, width, thickness)));
93+
94+
new StringDrawer("MUL").at(size / 2, size * 9 / 10)
95+
.font(new Font("SansSerif", Font.BOLD, size))
96+
.centerX()
97+
.maxWidth(size * 9 / 10)
98+
.draw(g);
99+
}
100+
101+
102+
private static Shape createLink(double length, double width, double thickness) {
103+
Area link = new Area(new RoundRectangle2D.Double(0, 0, length, width, width, width));
104+
link.subtract(new Area(new RoundRectangle2D.Double(thickness, thickness, length - 2 * thickness,
105+
width - 2 * thickness, width - thickness, width - thickness)));
106+
return link;
107+
}
108+
}

0 commit comments

Comments
 (0)