Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
added Hide parameters and galaxy secondary options
Browse files Browse the repository at this point in the history
  • Loading branch information
BrokenRegistry committed Jul 5, 2022
1 parent e6cc60a commit 84572e5
Show file tree
Hide file tree
Showing 32 changed files with 2,026 additions and 266 deletions.
1,279 changes: 1,279 additions & 0 deletions Profiles.cfg

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ Download build: https://rayfowler.itch.io/remnants-of-the-precursors

## What'New

2026.07.05
- Added secondary options for Galaxy shapes.
- Added possibility to hide parameters in Profiles.cfg

2026.07.01
- Junit test integration
- Junit test integration to github
- Pom file normalization
- Minor bugs solved

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- Project Declaration -->
<groupId>com.rayfowler</groupId>
<artifactId>rotp</artifactId>
<version>2022.07.01</version>
<version>2022.07.05</version>
<packaging>jar</packaging>

<!-- Variables Declaration -->
Expand Down
10 changes: 8 additions & 2 deletions src/br/profileManager/src/main/java/AbstractGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ public abstract class AbstractGroup<C> extends WriteUtil {
LinkedHashMap<String, AbstractParameter<?, ?, C>>
parameterNameMap = new LinkedHashMap<String,
AbstractParameter<?, ?, C>>();

private String headerComment= "";
// ========================================================================
// Constructor
//
protected AbstractGroup(C clientObject) {
initSettingList(clientObject);
}
protected AbstractGroup(C clientObject, String comment) {
initSettingList(clientObject);
if (comment != null) {
headerComment = comment;
}
}
// ========================================================================
// Abstract Methods
//
Expand Down Expand Up @@ -102,7 +108,7 @@ public List<String> profileList() {
* @return parameters group as String, ready to be printed
*/
public String toString(List<String> profileList, boolean cleanProfiles) {
String out = "";
String out = toComment(headerComment) + NL + emptyCommentLines(1);
for (AbstractParameter<?, ?, C>
parameter : parameterNameMap.values() ) {
if (cleanProfiles) {
Expand Down
39 changes: 32 additions & 7 deletions src/br/profileManager/src/main/java/AbstractParameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public abstract class AbstractParameter<
private static String historyHead = lineFormat("¦ History", "");
private static String historyKey = "¦ History";
private static String parameterKey = "¦==== Parameter";
private static String hiddenKey = "HIDE";
private static String hideSeparator = "-";
private static String historyElementsSeparator = " ¦ ";
private static String historyNameValueSeparator = ": ";
private static String availableForChange = "---- Available for changes in game saves";
Expand Down Expand Up @@ -70,11 +72,13 @@ void resetUserProfiles() {
}

public static void newConfig(PMconfig PM) {
optionsHead = lineFormat(toComment(PM.getConfig("optionsKey")), "");
optionsSubHead = lineFormat(toComment(PM.getConfig("optionsSubKey")), "");
historyHead = lineFormat(PM.getConfig("historyKey"), "");
historyKey = PM.getConfig("historyKey");
parameterKey = PM.getConfig("parameterKey");
optionsHead = lineFormat(toComment(PM.getConfig("optionsKey")), "");
optionsSubHead = lineFormat(toComment(PM.getConfig("optionsSubKey")), "");
historyHead = lineFormat(PM.getConfig("historyKey"), "");
historyKey = PM.getConfig("historyKey");
parameterKey = PM.getConfig("parameterKey");
hiddenKey = PM.getConfig("hiddenKey");
hideSeparator = PM.getConfig("hideSeparator");
historyElementsSeparator = PM.getConfig("historyElementsSeparator");
historyNameValueSeparator = PM.getConfig("historyNameValueSeparator");
availableForChange = PM.getConfig("availableForChange");
Expand Down Expand Up @@ -133,6 +137,18 @@ private AbstractT<T> getWinningCodeView (List<String> profileNames) {
return value;
}

boolean isHidden() {
return localEnable.isHidden();
}
void setHidden() {
localEnable.setHidden();
}
void unHide() {
localEnable.unHide();
}
void setLocalEnable(String value) {
localEnable.setValue(value);
}
/**
* Search for the winning code View and
* Override the Game File parameter with it
Expand Down Expand Up @@ -463,6 +479,13 @@ void forceCreationMissingProfile(List<String> profileList) {
public String toString(List<String> groupCodeViews) {
String out = NL;

if(isHidden()) {
// SETTING NAME
out += lineFormat(parameterKey
, parameterName + " " + hideSeparator + hiddenKey)
.toString() + NL;
return out;
}
// HEAD COMMENTS
out += multiLines(headComments
, " ", commentPrt(), commentPrt(), "", true);
Expand All @@ -476,8 +499,10 @@ public String toString(List<String> groupCodeViews) {
, " ", commentPrt(), commentPrt(), "", true);

// OPTIONS LIST
out += multiLines(validation.getOptionsRange()
, " " ,optionsHead, optionsSubHead, "", true);
if (validation.getCriteria().showOptions()) {
out += multiLines(validation.getOptionsRange()
, " " ,optionsHead, optionsSubHead, "", true);
}

// OPTIONS DESCRIPTION
out += toCommentLine(validation.getOptionsDescription(), 1, 1);
Expand Down
34 changes: 26 additions & 8 deletions src/br/profileManager/src/main/java/AbstractProfiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ public abstract class AbstractProfiles<C> extends WriteUtil {
//
protected static final PMconfig PM = new PMconfig();
// Keep the initializations for Junit test
private static String continueOnNewLine = "..";
private static String commentKey = ";";
private static String breakLine = "..";
private static String commentKey = ";";
private static String hiddenKey = "HIDE";
private static String hideSeparator = "-";

private List<String> defaultUserSettingKeys = new ArrayList<String>(List.of("User", "LastWord"));
private boolean firstInit = true;
Expand All @@ -55,7 +57,8 @@ public abstract class AbstractProfiles<C> extends WriteUtil {
private boolean cleanUserKeys = true;

private AbstractParameter<?, ?, C> currentParameter;
private String currentParameterName;
private String currentParameterName;
private boolean currentParameterIsHidden = false;
private AbstractGroup<C> currentGroup;

// ==================================================
Expand All @@ -73,8 +76,10 @@ public AbstractProfiles(String jarPath, String configFileName) {
* To be notified the config has been updated
*/
static void newConfig(PMconfig PM) {
continueOnNewLine = PM.getConfig("continueOnNewLine");
commentKey = PM.getConfig("commentKey");
breakLine = PM.getConfig("breakLine");
commentKey = PM.getConfig("commentKey");
hiddenKey = PM.getConfig("hiddenKey").toUpperCase();
hideSeparator = PM.getConfig("hideSeparator");
}
// ========================================================================
// Abstract Methods
Expand Down Expand Up @@ -351,7 +356,7 @@ private void loadProfilesCfg() {
String line;
while ((line = in.readLine()) != null) {
line = line.trim();
while (line.endsWith(continueOnNewLine)) {
while (line.endsWith(breakLine)) {
line = mergeLines(line, in.readLine());
}
processLine(line.trim());
Expand Down Expand Up @@ -405,24 +410,37 @@ private void processLine(String line) {
}
// Test for New Setting Section
if (AbstractParameter.isHeadOfParameter(key) ) {
currentParameterName = Lines.getValueAsString(line).toUpperCase();
String local = Valid_LocalEnable.DEFAULT_VALUE;
currentParameterIsHidden = false;
String[] elements = Lines.getValueAsString(line)
.toUpperCase().split(hideSeparator, 2);
currentParameterName = elements[0].strip();
if (elements.length == 2) {
local = elements[1].strip();
if (local.equalsIgnoreCase(hiddenKey)) {
currentParameterIsHidden = true;
}
}
// Test if initial profile list declaration
if (parameterProfileAction.getParameterName()
.equalsIgnoreCase(currentParameterName)) {
currentParameter = parameterProfileAction;
currentParameterIsHidden = false; // big problem if hidden!
currentGroup = null;
return;
}
currentGroup = groupNameMap.get(currentParameterName);
currentParameter = null;
if (currentGroup != null) {
currentParameter = currentGroup.getParameter(currentParameterName);
currentParameter.setLocalEnable(local);
return;
}
return;
}
// it's a setting Line
if (currentParameter != null) {
if (currentParameter != null
&& !currentParameterIsHidden) {
currentParameter.addLine(line);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/br/profileManager/src/main/java/Lines.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private Lines() {} // Forbidden constructor
static void newConfig(PMconfig PM) {
keyValueSeparator = PM.getConfig("keyValueSeparator");
keyValueSeparatorPrt = keyValueSeparator + PM.getConfig("valueSpacer");
profilesBreakLines = " " + PM.getConfig("continueOnNewLine");
profilesBreakLines = " " + PM.getConfig("breakLine");
baseKeyFormat = "%-" + PM.getConfig("lineSplitPosition") + "s";
keyFormat = baseKeyFormat + keyValueSeparatorPrt;
keyValueFormat = "%-" + PM.getConfig("commentEndPosition") + "s";
Expand Down
4 changes: 3 additions & 1 deletion src/br/profileManager/src/main/java/PMconfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface NewConfig {
PMconfig() {
config.put("commentKey", ";");
config.put("commentSpacer", " ");
config.put("continueOnNewLine", "..");
config.put("breakLine", "..");
config.put("keyValueSeparator", ":");
config.put("valueSpacer", " ");
config.put("separatorSymbol", "=");
Expand All @@ -62,6 +62,8 @@ interface NewConfig {
config.put("clogId", "·");
config.put("randomId", "RANDOM");
config.put("parameterKey", "¦==== Parameter");
config.put("hiddenKey", "Hide");
config.put("hideSeparator", "-");
config.put("historyKey", "¦ History");
config.put("optionsKey", "Options");
config.put("--------------------", "----------");
Expand Down
51 changes: 37 additions & 14 deletions src/br/profileManager/src/main/java/PMutil.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ static String addLinebreaks(String input, String splitter,
}
return String.join(System.lineSeparator(), lines);
}

/**
* Remove first Space if one.
* Originally done to restore original comment
Expand All @@ -286,7 +285,6 @@ static String removeFirstSpace (String string) {
}
return string;
}

/**
* Remove last Space if one. Never null.
* @param string the {@code String} to process
Expand All @@ -301,7 +299,6 @@ static String removeLastSpace (String string) {
}
return string;
}

/**
* Get the last char of the {@code String}
* @param string the {@code String} to process
Expand All @@ -313,7 +310,6 @@ static String getLastChar(String string) {
}
return string.substring(string.length() - 1);
}

/**
* Convert {@code objects} to {@code String}
* null {@code objects} are replaced by Empty {@code String}
Expand All @@ -326,7 +322,6 @@ static String neverNull(Object obj) {
}
return obj.toString();
}

/**
* Convert {@code objects} to {@code String} and strip them.
* null {@code objects} are replaced by Empty {@code String}
Expand All @@ -339,7 +334,6 @@ public static String clean(Object obj) {
}
return obj.toString().strip();
}

/**
* Strip and convert to upper case
* @param source the {@code String} to process
Expand All @@ -348,7 +342,6 @@ public static String clean(Object obj) {
static String toKey(String source) {
return clean(source).toUpperCase();
}

/**
* Strip and return in lower case with first char to upper case, never null
* @param source the {@code String} to process
Expand All @@ -366,7 +359,6 @@ static String toSentence(String source) {
}
return result.strip();
}

/**
* Strip and return every word capitalized, never null
* @param source the {@code String} to process
Expand All @@ -384,7 +376,6 @@ public static String capitalize(String source) {
}
return result;
}

/**
* Strip and return every word capitalized, never null
* or only first word
Expand All @@ -400,36 +391,68 @@ static String capitalize(String source, boolean onlyFirstWord) {
return capitalize(source);
}
}

/**
* @param str Containing String
* @param target String to find
* @return The number of Occurrence
*/
public static int countStringOccurrence(String str, String target) {
return (str.length() - str.replace(target, "").length()) / target.length();
}
/**
* Convert a {@code String} with several "_" to a more user friendly one
* @param option the {@code String} Option
* @param minLength the minimal length of the two las elements String
* @return the capitalized last element of the {@code String} (after "_")
*/
static String suggestedUserViewFromCodeView (Object value) {
static String suggestedUserViewFromCodeView (Object value, int minLength) {
if (value == null) {
return "null";
}
String codeView = value.toString();
if (codeView == null) {
return "null";
}
return toSentence(codeView.substring(codeView.lastIndexOf("_") + 1));
String[] elements = codeView.split("_", 0);
int last = elements.length-1;
if (last > 1 &&
(elements[last-1].length() <= minLength
|| elements[last].length() <= minLength)) {
return capitalize(elements[last-1]) + "_" + capitalize(elements[last]);
}
return capitalize(elements[last]);
}
/**
* Convert a {@code String} with several "_" to a more user friendly one
* @param option the {@code String} Option
* @return the capitalized last element of the {@code String} (after "_")
*/
static String suggestedUserViewFromCodeView (Object value) {
return suggestedUserViewFromCodeView (value, 1);
}
/**
* Convert a {@code String} with several "_" to a more user friendly one
* @param list the {@code List<String>} Option
* @param minLength the minimal length of the two las elements String
* @return the capitalized last element of the {@code String} (after "_")
*/
public static List<String> suggestedUserViewFromCodeView (List<?> list) {
public static List<String> suggestedUserViewFromCodeView (List<?> list, int minLength) {
List<String> result = new ArrayList<String>();
if (list != null) {
for (Object value : list) {
result.add(suggestedUserViewFromCodeView(value));
result.add(suggestedUserViewFromCodeView(value, minLength));
}
}
return result;
}
/**
* Convert a {@code String} with several "_" to a more user friendly one
* @param list the {@code List<String>} Option
* @return the capitalized last element of the {@code String} (after "_")
*/
public static List<String> suggestedUserViewFromCodeView (List<?> list) {
return suggestedUserViewFromCodeView (list, 1);
}

// ==================================================
// Math Methods
Expand Down
6 changes: 0 additions & 6 deletions src/br/profileManager/src/main/java/PMutilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,6 @@ void suggestedOptionToLabel_String() {
, "should have been «Source»");
assertEquals("Source", suggestedUserViewFromCodeView("VERY_OPTION_SOURCE")
, "should have been «Source»");
assertEquals("Source", suggestedUserViewFromCodeView("OPTION__SOURCE")
, "should have been «Source»");
assertEquals("Source", suggestedUserViewFromCodeView("_SOURCE")
, "should have been «Source»");
assertEquals("Source", suggestedUserViewFromCodeView("__SOURCE")
, "should have been «Source»");
}

// ==================================================
Expand Down
Loading

0 comments on commit 84572e5

Please sign in to comment.