mirror of
https://github.com/processing/processing4.git
synced 2026-01-27 18:31:07 +01:00
add naming options as preference
This commit is contained in:
@@ -15,6 +15,7 @@ import java.util.Map;
|
||||
|
||||
|
||||
public class SketchName {
|
||||
static final String CLASSIC_NAME = "Classic (sketch_220809a)";
|
||||
static boolean breakTime = false;
|
||||
|
||||
static Map<String, WordList> wordLists;
|
||||
@@ -29,8 +30,15 @@ public class SketchName {
|
||||
* @return File object for safe new path, or null if there were problems
|
||||
*/
|
||||
static File nextFolder(File parentDir) {
|
||||
//return classicFolder(parentDir);
|
||||
return wordsFolder(parentDir);
|
||||
String approach = Preferences.get("sketch.name.approach");
|
||||
if (!approach.equals(CLASSIC_NAME)) {
|
||||
File folder = wordsFolder(parentDir, approach);
|
||||
if (folder != null) {
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
// classic was selected, or fallback due to an error
|
||||
return classicFolder(parentDir);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +114,19 @@ public class SketchName {
|
||||
}
|
||||
|
||||
|
||||
static File wordsFolder(File parentDir) {
|
||||
static File wordsFolder(File parentDir, String setName) {
|
||||
WordList wl = getWordLists().get(setName);
|
||||
File outgoing = null;
|
||||
if (wl != null) {
|
||||
do {
|
||||
outgoing = new File(parentDir, wl.getPair());
|
||||
} while (outgoing.exists());
|
||||
}
|
||||
return outgoing;
|
||||
}
|
||||
|
||||
|
||||
static Map<String, WordList> getWordLists() {
|
||||
if (wordLists == null) {
|
||||
wordLists = new HashMap<>();
|
||||
try {
|
||||
@@ -121,12 +141,16 @@ public class SketchName {
|
||||
Messages.showWarning("Naming Error", "Could not load word lists from naming.json", e);
|
||||
}
|
||||
}
|
||||
final String setName = "Cooking";
|
||||
WordList wl = wordLists.get(setName);
|
||||
File outgoing;
|
||||
do {
|
||||
outgoing = new File(parentDir, wl.getPair());
|
||||
} while (outgoing.exists());
|
||||
return outgoing;
|
||||
return wordLists;
|
||||
}
|
||||
|
||||
|
||||
static public String[] getOptions() {
|
||||
StringList outgoing = new StringList();
|
||||
outgoing.append(CLASSIC_NAME);
|
||||
for (String approach : getWordLists().keySet()) {
|
||||
outgoing.append(approach);
|
||||
}
|
||||
return outgoing.array();
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import processing.app.Language;
|
||||
import processing.app.Messages;
|
||||
import processing.app.Platform;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.SketchName;
|
||||
import processing.awt.ShimAWT;
|
||||
import processing.core.*;
|
||||
|
||||
@@ -53,6 +54,8 @@ public class PreferencesFrame {
|
||||
static final Integer[] FONT_SIZES = { 10, 12, 14, 18, 24, 36, 48 };
|
||||
|
||||
JTextField sketchbookLocationField;
|
||||
JComboBox<String> namingSelectionBox;
|
||||
|
||||
JTextField presentColor;
|
||||
//JCheckBox editorAntialiasBox;
|
||||
// JCheckBox deletePreviousBox;
|
||||
@@ -144,6 +147,12 @@ public class PreferencesFrame {
|
||||
);
|
||||
|
||||
|
||||
// Sketch Naming: [ Classic (sketch_220822a) ]
|
||||
|
||||
JLabel namingLabel = new JLabel(Language.text("preferences.sketch_naming"));
|
||||
namingSelectionBox = new JComboBox<>(SketchName.getOptions());
|
||||
|
||||
|
||||
// Language: [ English ] (requires restart of Processing)
|
||||
|
||||
JLabel languageLabel = new JLabel(Language.text("preferences.language"));
|
||||
@@ -460,6 +469,8 @@ public class PreferencesFrame {
|
||||
|
||||
addRow(axis, sketchbookLocationLabel, sketchbookLocationField);
|
||||
|
||||
addRow(axis, namingLabel, namingSelectionBox);
|
||||
|
||||
//
|
||||
|
||||
JPanel layoutPanel = new JPanel();
|
||||
@@ -663,6 +674,8 @@ public class PreferencesFrame {
|
||||
base.setSketchbookFolder(new File(newPath));
|
||||
}
|
||||
|
||||
Preferences.set("sketch.name.approach", (String) namingSelectionBox.getSelectedItem());
|
||||
|
||||
// setBoolean("editor.external", externalEditorBox.isSelected());
|
||||
Preferences.setBoolean("update.check", checkUpdatesBox.isSelected()); //$NON-NLS-1$
|
||||
|
||||
@@ -802,6 +815,8 @@ public class PreferencesFrame {
|
||||
// deletePreviousBox.setSelected(Preferences.getBoolean("export.delete_target_folder")); //$NON-NLS-1$
|
||||
|
||||
sketchbookLocationField.setText(Preferences.getSketchbookPath());
|
||||
namingSelectionBox.setSelectedItem(Preferences.get("sketch.name.approach"));
|
||||
|
||||
checkUpdatesBox.setSelected(Preferences.getBoolean("update.check")); //$NON-NLS-1$
|
||||
|
||||
defaultDisplayNum = updateDisplayList();
|
||||
|
||||
@@ -231,6 +231,9 @@ editor.untitled.suffix=yyMMdd
|
||||
# replace underscores in .pde file names with spaces
|
||||
sketch.name.replace_underscore = true
|
||||
|
||||
# what to use for generating sketch names (change in the prefs window)
|
||||
#sketch.name.approach =
|
||||
|
||||
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
|
||||
@@ -193,6 +193,7 @@ preferences.button.width = 80
|
||||
preferences.restart_required = Restart Processing to apply changes
|
||||
preferences.sketchbook_location = Sketchbook folder
|
||||
preferences.sketchbook_location.popup = Sketchbook folder
|
||||
preferences.sketch_naming = Sketch name
|
||||
preferences.language = Language:
|
||||
preferences.editor_and_console_font = Editor and Console font:
|
||||
preferences.editor_and_console_font.tip = Select the font used in the Editor and the Console.<br>Only monospaced (fixed-width) fonts may be used,<br>though the list may be imperfect.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"name": "\"Friendly\" Names",
|
||||
"name": "“Friendly” Names",
|
||||
"notes": "From https://github.com/glitchdotcom/friendly-words as of 2022-08-02",
|
||||
"prefixes": [
|
||||
"aback",
|
||||
@@ -4522,7 +4522,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Cooking",
|
||||
"name": "Cooking with Paul",
|
||||
"notes": "Developed by Paul Cronan of Fathom Information Design (https://fathom.info)",
|
||||
"prefixes": [
|
||||
"cooking",
|
||||
|
||||
20
todo.txt
20
todo.txt
@@ -29,6 +29,16 @@ X close the interface issue, major changes done
|
||||
X remove underscore and use (half?) space for tabs?
|
||||
X half space character not implemented, but the space looks good
|
||||
X disable behavior with sketch.name.replace_underscore = false
|
||||
X add other naming options (cooking and classic) and prefs
|
||||
X "friendly" naming for sketches
|
||||
X master list of words
|
||||
X https://github.com/glitchdotcom/friendly-words/tree/master/words
|
||||
X exact sources
|
||||
X https://github.com/glitchdotcom/friendly-words/blob/master/words/predicates.txt
|
||||
X https://github.com/glitchdotcom/friendly-words/blob/master/words/objects.txt
|
||||
X how friendly names are used in the p5.js web editor
|
||||
X https://github.com/processing/p5.js-web-editor/blob/develop/client/utils/generateRandomName.js
|
||||
X p5.js uses predicate followed by an object
|
||||
|
||||
bugs
|
||||
X re-post bugzilla entries at https://download.processing.org/bugzilla/
|
||||
@@ -334,7 +344,6 @@ X re-save svg files using svg 1.0
|
||||
X sort out hover/press states here (only hovers atm)
|
||||
X also add state for shift-click to search
|
||||
_ theme colors for emoji buttons (new themes across the board)
|
||||
_ naming options?
|
||||
_ reset the theme because of significant changes
|
||||
_ move away from writing theme.txt?
|
||||
_ instead store the theme name, for easier updating
|
||||
@@ -372,15 +381,6 @@ _ Base.checkSketchFolder() is used to identify sketches for the sketchbook frame
|
||||
_ but it assumes that it's folder name + default extension as the name for it
|
||||
_ that should be moved into the Mode class as a "is this folder a sketch" call
|
||||
_ (so that Modes can work differently too)
|
||||
_ "friendly" naming for sketches
|
||||
_ master list of words
|
||||
_ https://github.com/glitchdotcom/friendly-words/tree/master/words
|
||||
_ exact sources
|
||||
_ https://github.com/glitchdotcom/friendly-words/blob/master/words/predicates.txt
|
||||
_ https://github.com/glitchdotcom/friendly-words/blob/master/words/objects.txt
|
||||
_ how friendly names are used in the p5.js web editor
|
||||
_ https://github.com/processing/p5.js-web-editor/blob/develop/client/utils/generateRandomName.js
|
||||
_ p5.js uses predicate followed by an object
|
||||
|
||||
|
||||
detach sketch names
|
||||
|
||||
Reference in New Issue
Block a user