Skip to content

Commit 12f640a

Browse files
authored
Merge pull request #7231 from IllianiBird/newGlossaryInitial
Improvement: Replaced Placeholder Glossary with New Layout and Functionality
2 parents 8536100 + bcd50da commit 12f640a

25 files changed

+2811
-209
lines changed

MekHQ/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ dependencies {
8181
implementation 'org.apache.commons:commons-text:1.13.1'
8282
implementation 'org.apache.logging.log4j:log4j-core:2.24.3'
8383

84+
implementation 'org.apache.pdfbox:pdfbox:3.0.5'
85+
8486
implementation 'org.commonmark:commonmark:0.24.0'
8587

8688
implementation 'org.jfree:jfreechart:1.5.6'
2.7 MB
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# suppress inspection "UnusedProperty" for the whole file
2+
AGING_EFFECTS.title=Aging
3+
AWARDS_MODULE.title=Awards
4+
EDUCATION_MODULE.title=Education
5+
RANDOM_DEATH.title=Random Death
6+
RANDOM_DEPENDENTS.title=Random Civilians
7+
RANDOM_PERSONALITIES.title=Random Personalities
8+
STARTING_ATTRIBUTE_SCORES.title=Starting Attribute Scores
9+
TURNOVER_AND_RETENTION.title=Turnover & Retention (feat. Fatigue)
10+
PRISONERS_OF_WAR.title=Prisoners of War & Abstracted Search and Rescue
11+
ACAR.title=ACAR (Abstract Combat AutoResolve)
12+
ADMIN_SKILLS.title=Admin Skills
13+
COMBAT_TEAMS.title=Combat Teams, Roles, Training & Reinforcements
14+
MORALE.title=MekHQ Morale
15+
RESUPPLY_AND_CONVOYS.title=Resupply & Convoys
16+
UNIT_MARKETS.title=Unit Markets
17+
CHAOS_CAMPAIGNS.title=Chaos Campaigns in MekHQ
18+
COOP_CAMPAIGNS.title=Co-op Campaigns in MekHQ
19+
AUTOMATIC_AMMO_ASSIGNMENT.title=Automatic Ammunition Tool
20+
NEW_PLAYER_GUIDE.title=New & Returning Player Guide

MekHQ/resources/mekhq/resources/GlossaryEntry.properties

Lines changed: 865 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
GlossaryDialog.title=++ACCESSING DATABASE++
2+
GlossaryDialog.contentsPane.title=<h2 style="text-align:center;">Contents</h2>
3+
GlossaryDialog.documentationPane.title=<h2 style="text-align:center;">Documentation</h2>
4+
GlossaryDialog.aboutPane=<h1 style="text-align:center;">MekHQ Glossary</h1>This Glossary includes a wealth of \
5+
information about MekHQ and its systems. It is, however, a work in progress. If there is something you think is \
6+
missing, or incomplete, please let us know!
7+
GlossaryDialog.button.close=Close
8+
GlossaryDialog.button.closeTab.single=Close Tab
9+
GlossaryDialog.button.closeTab.all=Close All
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*
2+
* Copyright (C) 2025 The MegaMek Team. All Rights Reserved.
3+
*
4+
* This file is part of MekHQ.
5+
*
6+
* MekHQ 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+
* MekHQ 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. MekHQ 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 mekhq.campaign.utilities.glossary;
34+
35+
import static mekhq.utilities.MHQInternationalization.getTextAt;
36+
37+
import java.util.List;
38+
39+
/**
40+
* The {@code DocumentationEntry} enum represents individual entries in the documentation glossary.
41+
*
42+
* <p>Each enum constant is associated with a lookup name used to fetch localized strings.</p>
43+
*
44+
* <p>This class provides methods to retrieve localized titles, sort entries, and look up entries by name.</p>
45+
*
46+
* @author Illiani
47+
* @since 0.50.07
48+
*/
49+
public enum DocumentationEntry {
50+
AGING_EFFECTS("AGING_EFFECTS", "Personnel Modules/Aging Effects"),
51+
AWARDS_MODULE("AWARDS_MODULE", "Personnel Modules/Awards Module"),
52+
EDUCATION_MODULE("EDUCATION_MODULE", "Personnel Modules/Education Module"),
53+
RANDOM_DEATH("RANDOM_DEATH", "Personnel Modules/Random Death in MekHQ"),
54+
RANDOM_DEPENDENTS("RANDOM_DEPENDENTS", "Personnel Modules/Random Dependents"),
55+
RANDOM_PERSONALITIES("RANDOM_PERSONALITIES", "Personnel Modules/Random Personalities"),
56+
STARTING_ATTRIBUTE_SCORES("STARTING_ATTRIBUTE_SCORES", "Personnel Modules/Starting Attribute Scores"),
57+
TURNOVER_AND_RETENTION("TURNOVER_AND_RETENTION", "Personnel Modules/Turnover & Retention Module (feat. Fatigue)"),
58+
PRISONERS_OF_WAR("PRISONERS_OF_WAR", "Random Events/Prisoners of War & Abstracted Search and Rescue"),
59+
ACAR("ACAR", "StratCon/ACAR-Abstract Combat Auto-Resolve documentation"),
60+
ADMIN_SKILLS("ADMIN_SKILLS", "StratCon/Admin Skills"),
61+
COMBAT_TEAMS("COMBAT_TEAMS", "StratCon/Combat Teams, Roles, Training & Reinforcements"),
62+
MORALE("MORALE", "StratCon/MekHQ Morale"),
63+
RESUPPLY_AND_CONVOYS("RESUPPLY_AND_CONVOYS", "StratCon/Resupply & Convoys"),
64+
UNIT_MARKETS("UNIT_MARKETS", "StratCon/Unit Markets"),
65+
CHAOS_CAMPAIGNS("CHAOS_CAMPAIGNS", "MegaMek -MekHQ Chaos Campaign Guide"),
66+
COOP_CAMPAIGNS("COOP_CAMPAIGNS", "MekHQ Co-Op Campaign Guide v1"),
67+
NEW_PLAYER_GUIDE("NEW_PLAYER_GUIDE", "0_MHQ New Player Guide");
68+
69+
private static final String RESOURCE_BUNDLE = "mekhq.resources.DocumentationEntry";
70+
71+
private final String DIRECTORY = "docs/";
72+
private final String FILE_EXTENSION = ".pdf";
73+
74+
private final String lookUpName;
75+
private final String fileAddress;
76+
77+
/**
78+
* Constructs a {@code DocumentationEntry} with the specified lookup name.
79+
*
80+
* @param lookUpName the resource key used to look up this entry's localized strings
81+
* @param fileAddress the document address
82+
*
83+
* @author Illiani
84+
* @since 0.50.07
85+
*/
86+
DocumentationEntry(String lookUpName, String fileAddress) {
87+
this.lookUpName = lookUpName;
88+
this.fileAddress = fileAddress;
89+
}
90+
91+
/**
92+
* Returns the localized title for this documentation entry.
93+
*
94+
* @return the title string for this entry
95+
*
96+
* @author Illiani
97+
* @since 0.50.07
98+
*/
99+
public String getTitle() {
100+
return getTextAt(RESOURCE_BUNDLE, lookUpName + ".title");
101+
}
102+
103+
/**
104+
* Returns the full file address for this object by concatenating the directory path, the stored file address, and
105+
* the file extension constants.
106+
*
107+
* @return the complete file address as a String
108+
*
109+
* @author Illiani
110+
* @since 0.50.07
111+
*/
112+
public String getFileAddress() {
113+
return DIRECTORY + fileAddress + FILE_EXTENSION;
114+
}
115+
116+
/**
117+
* Returns a list of all lookup names, sorted by their corresponding localized titles in ascending order.
118+
*
119+
* @return a list of lookup names sorted by title
120+
*
121+
* @author Illiani
122+
* @since 0.50.07
123+
*/
124+
public static List<String> getLookUpNamesSortedByTitle() {
125+
return java.util.Arrays.stream(DocumentationEntry.values())
126+
.sorted(java.util.Comparator.comparing(DocumentationEntry::getTitle))
127+
.map(entry -> entry.lookUpName)
128+
.toList();
129+
}
130+
131+
/**
132+
* Returns the {@code DocumentationEntry} associated with the given lookup name, or {@code null} if not found.
133+
*
134+
* @param lookUpName the lookup name to search for
135+
*
136+
* @return the corresponding {@code DocumentationEntry} if found; {@code null} otherwise
137+
*
138+
* @author Illiani
139+
* @since 0.50.07
140+
*/
141+
public static DocumentationEntry getDocumentationEntryFromLookUpName(String lookUpName) {
142+
for (DocumentationEntry entry : DocumentationEntry.values()) {
143+
if (entry.lookUpName.equals(lookUpName)) {
144+
return entry;
145+
}
146+
}
147+
return null;
148+
}
149+
}

0 commit comments

Comments
 (0)