Begin refactoring to use processing 2

This commit is contained in:
Sandy Noble 2013-09-01 18:25:33 +01:00
parent 51c34e65d2
commit f0a45e3a19
3 changed files with 19 additions and 19 deletions

View File

@ -446,11 +446,11 @@ void button_mode_selectPictureframe()
} }
void button_mode_exportQueue() void button_mode_exportQueue()
{ {
exportQueueToFile(); selectOutput("Save queue as...", "exportQueueToFile"); // Opens file chooser
} }
void button_mode_importQueue() void button_mode_importQueue()
{ {
importQueueFromFile(); selectInput("Choose a file to import a queue from...", "importQueueFromFile");
} }
void toggle_mode_drawDirect(boolean flag) void toggle_mode_drawDirect(boolean flag)
{ {

View File

@ -316,7 +316,6 @@ void submitDrawWindow(int theValue)
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
Details about the "writing" subwindow Details about the "writing" subwindow
------------------------------------------------------------------------*/ ------------------------------------------------------------------------*/
String textToWrite = "";
String spriteFilePrefix = "sprite/let"; String spriteFilePrefix = "sprite/let";
String spriteFileSuffix = ".txt"; String spriteFileSuffix = ".txt";
@ -361,12 +360,12 @@ void spriteFilePrefixField(String value)
} }
void textToWriteField(String value) void textToWriteField(String value)
{ {
textToWrite = value; textForVectorSprite = value;
} }
String getTextToWrite() String getTextToWrite()
{ {
return textToWrite; return textForVectorSprite;
} }
String getSpriteFilePrefix() String getSpriteFilePrefix()
{ {
@ -379,7 +378,8 @@ String getSpriteFileSuffix()
void importTextButton() void importTextButton()
{ {
textToWrite = importTextToWriteFromFile(); // This loads the file contents into the variable called textForVectorSprite
selectInput("Choose a text file to load from...", "importTextToWriteFromFile");
Textfield tf = (Textfield) cp5.controller("textToWriteField"); Textfield tf = (Textfield) cp5.controller("textToWriteField");
tf.setText(getTextToWrite()); tf.setText(getTextToWrite());
tf.submit(); tf.submit();

View File

@ -504,6 +504,9 @@ String shapeSaveExtension = ".svg";
//PImage dpadXImage = null; //PImage dpadXImage = null;
//PImage dpadYImage = null; //PImage dpadYImage = null;
// The block of text imported from file, used for the vector sprite writing
String textForVectorSprite = "";
void setup() void setup()
{ {
println("Running polargraph controller"); println("Running polargraph controller");
@ -1819,12 +1822,11 @@ void sizeImageToFitBox()
getDisplayMachine().setImageFrame(r); getDisplayMachine().setImageFrame(r);
} }
void exportQueueToFile() void exportQueueToFile(File selectedFile)
{ {
if (!commandQueue.isEmpty() || !realtimeCommandQueue.isEmpty()) if (!commandQueue.isEmpty() || !realtimeCommandQueue.isEmpty())
{ {
String savePath = selectOutput(); // Opens file chooser if (selectedFile == null)
if (savePath == null)
{ {
// If a file was not selected // If a file was not selected
println("No output file was selected..."); println("No output file was selected...");
@ -1832,38 +1834,36 @@ void exportQueueToFile()
else else
{ {
// If a file was selected, print path to folder // If a file was selected, print path to folder
println("Output file: " + savePath); println("Output file: " + selectedFile);
List<String> allCommands = new ArrayList<String>(realtimeCommandQueue); List<String> allCommands = new ArrayList<String>(realtimeCommandQueue);
allCommands.addAll(commandQueue); allCommands.addAll(commandQueue);
String[] list = (String[]) allCommands.toArray(new String[0]); String[] list = (String[]) allCommands.toArray(new String[0]);
saveStrings(savePath, list); saveStrings(selectedFile, list);
println("Completed queue export, " + list.length + " commands exported."); println("Completed queue export, " + list.length + " commands exported.");
} }
} }
} }
void importQueueFromFile() void importQueueFromFile(File selectedFile)
{ {
commandQueue.clear(); commandQueue.clear();
String loadPath = selectInput(); if (selectedFile == null)
if (loadPath == null)
{ {
// nothing selected // nothing selected
println("No input file was selected."); println("No input file was selected.");
} }
else else
{ {
println("Input file: " + loadPath); println("Input file: " + selectedFile);
String commands[] = loadStrings(loadPath); String commands[] = loadStrings(selectedFile);
// List<String> list = Arrays // List<String> list = Arrays
commandQueue.addAll(Arrays.asList(commands)); commandQueue.addAll(Arrays.asList(commands));
println("Completed queue import, " + commandQueue.size() + " commands found."); println("Completed queue import, " + commandQueue.size() + " commands found.");
} }
} }
String importTextToWriteFromFile() void importTextToWriteFromFile(File loadPath)
{ {
String loadPath = selectInput();
String result = ""; String result = "";
if (loadPath == null) if (loadPath == null)
{ {
@ -1882,8 +1882,8 @@ String importTextToWriteFromFile()
result = sb.toString(); result = sb.toString();
println("Completed text import, " + result.length() + " characters found."); println("Completed text import, " + result.length() + " characters found.");
textForVectorSprite = result;
} }
return result;
} }