Просмотр исходного кода

Fixed method overloading for const char * initialized ObjectEntry's, fixed input on UIComboBox, IDE project data now stored in PolycodeProject, projects now resaved before building and files parsed in

Ivan Safrin 13 лет назад
Родитель
Сommit
0e027f9626

+ 16 - 0
Core/Contents/Include/PolyObject.h

@@ -137,6 +137,22 @@ namespace Polycode {
 			return entry;			
 		}		
 		
+		/**
+		* Adds an empty child entry with a string value.
+		* @param name Lookup key for the object entry.
+		* @param val String to set as value in the object entry.
+		* @return The added object entry.
+		*/						
+		ObjectEntry *addChild(const String& name, const char *val) {
+			ObjectEntry *entry = new ObjectEntry();
+			entry->type = ObjectEntry::STRING_ENTRY;
+			entry->stringVal = val;
+			entry->name = name;
+			children.push_back(entry);
+			length = children.size();			
+			return entry;			
+		}		
+		
 
 		/**
 		* Adds an empty child entry with a boolean value.

+ 29 - 0
IDE/Contents/Include/PolycodeProject.h

@@ -23,19 +23,48 @@
 #pragma once
 
 #include "Polycode.h"
+#include "OSBasics.h"
 
 using namespace Polycode;
 
+class ProjectData {
+	public:
+		String entryPoint;
+		int defaultWidth;
+		int defaultHeight;
+		bool vSync;	
+		unsigned int anisotropy;	
+		unsigned int aaLevel;
+		unsigned int frameRate;
+		
+		std::vector<String> modules;
+		
+		Number backgroundColorR;
+		Number backgroundColorG;
+		Number backgroundColorB;				
+};
+
 class PolycodeProject {
 	public:
 		PolycodeProject(String name, String path, String file);
 		~PolycodeProject();	
+		
+		bool loadProjectFromFile();	
+		bool saveFile();
 	
 		String getProjectName() { return projectName; }
 		String getProjectFile() { return projectFile; }	
 		String getRootFolder() { return projectFolder; }	
 	
+		ProjectData data;
+		
 private:
+
+
+	Object configFile;
+	
+	String filPath;
+		
 	String projectFile;
 	String projectFolder;	
 	String projectName;

+ 15 - 5
IDE/Contents/Include/PolycodeProjectEditor.h

@@ -25,21 +25,25 @@
 #include "PolycodeGlobals.h"
 #include "PolycodeUI.h"
 #include "PolycodeEditor.h"
+#include "PolycodeProject.h"
+#include "PolycodeProjectManager.h"
 #include <Polycode.h>
 
 using namespace Polycode;
 
 class PolycodeProjectEditor : public PolycodeEditor {
 	public:
-	PolycodeProjectEditor();
+	PolycodeProjectEditor(PolycodeProjectManager *projectManager);
 	virtual ~PolycodeProjectEditor();
 	
 	bool openFile(OSFileEntry filePath);
 	void Resize(int x, int y);
-	void saveFile();
-	
+	void saveFile();	
+		
 	protected:
 	
+	PolycodeProjectManager *projectManager;
+	
 	ScreenImage *grid;
 
 	Object configFile;	
@@ -58,10 +62,16 @@ class PolycodeProjectEditor : public PolycodeEditor {
 	UITextInput *entryPointInput;	
 	UIColorBox *bgColorBox;
 	
+	
+	PolycodeProject *associatedProject;
+	
 };
 
 class PolycodeProjectEditorFactory : public PolycodeEditorFactory {
 	public:
-		PolycodeProjectEditorFactory() : PolycodeEditorFactory() { extensions.push_back("polyproject"); }
-		PolycodeEditor *createEditor() { return new PolycodeProjectEditor(); }
+		PolycodeProjectEditorFactory(PolycodeProjectManager *projectManager);
+		PolycodeEditor *createEditor();
+		
+	protected:
+		PolycodeProjectManager *projectManager;	
 };

+ 2 - 0
IDE/Contents/Include/PolycodeProjectManager.h

@@ -49,6 +49,8 @@ class PolycodeProjectManager {
 	int getProjectCount() { return projects.size(); }
 	PolycodeProject *getProjectByIndex(int index) { return projects[index]; }
 	
+	PolycodeProject *getProjectByProjectFile(String projectFile);
+	
 	int removeProject(PolycodeProject *project);
 	
 	String activeFolder;

+ 2 - 2
IDE/Contents/Resources/UIThemes/default/theme.xml

@@ -5,7 +5,7 @@
 	<uiTextInputFontNameMultiLine>mono</uiTextInputFontNameMultiLine>
 	<uiDefaultFontSize>11</uiDefaultFontSize>
 	<uiTextInputFontSize>11</uiTextInputFontSize>
-	<uiTextInputFontSizeMultiline>11</uiTextInputFontSizeMultiline>	
+	<uiTextInputFontSizeMultiline>12</uiTextInputFontSizeMultiline>	
 	<uiTreeArrowIconImage>arrowIcon.png</uiTreeArrowIconImage>
 	<uiTreeCellHeight>20</uiTreeCellHeight>
 	<uiTreeCellPadding>4</uiTreeCellPadding>
@@ -77,7 +77,7 @@
 	<textBgSkinB>3</textBgSkinB>
 	<textBgSkinL>3</textBgSkinL>
 	<textBgSkinPadding>5</textBgSkinPadding>
-	<textEditLineSpacing>3</textEditLineSpacing>
+	<textEditLineSpacing>4</textEditLineSpacing>
 		
 	<uiScrollHandleMinSize>30</uiScrollHandleMinSize>	
 	<uiTreeContainerScrollBarOffset>27</uiTreeContainerScrollBarOffset>

+ 8 - 6
IDE/Contents/Source/PolycodeIDEApp.cpp

@@ -48,12 +48,6 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 	
 	editorManager = new PolycodeEditorManager();
 	
-	editorManager->registerEditorFactory(new PolycodeImageEditorFactory());
-	editorManager->registerEditorFactory(new PolycodeScreenEditorFactory());	
-	editorManager->registerEditorFactory(new PolycodeFontEditorFactory());
-	editorManager->registerEditorFactory(new PolycodeTextEditorFactory());
-	editorManager->registerEditorFactory(new PolycodeProjectEditorFactory());
-		
 	frame = new PolycodeFrame();
 	frame->setPositionMode(ScreenEntity::POSITION_TOPLEFT);
 
@@ -78,6 +72,14 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 	debugger = new PolycodeRemoteDebugger();
 	frame->console->setDebugger(debugger);
 	
+	editorManager->registerEditorFactory(new PolycodeImageEditorFactory());
+	editorManager->registerEditorFactory(new PolycodeScreenEditorFactory());	
+	editorManager->registerEditorFactory(new PolycodeFontEditorFactory());
+	editorManager->registerEditorFactory(new PolycodeTextEditorFactory());
+	editorManager->registerEditorFactory(new PolycodeProjectEditorFactory(projectManager));
+		
+	
+	
 //	CoreServices::getInstance()->getResourceManager()->addArchive(RESOURCE_PATH"tomato.polyapp");
 	
 //	ScreenImage *img = new ScreenImage("tomato.png");

+ 152 - 0
IDE/Contents/Source/PolycodeProject.cpp

@@ -30,6 +30,158 @@ PolycodeProject::PolycodeProject(String name, String path, String file) {
 	projectFolder = path;
 	projectFile = file;
 	
+	loadProjectFromFile();
+	
+}
+
+bool PolycodeProject::loadProjectFromFile() {
+
+	if(!configFile.loadFromXML(projectFile)) {
+		return false;
+	}
+	
+	if(configFile.root["entryPoint"]) {	
+		data.entryPoint = configFile.root["entryPoint"]->stringVal;
+	} else {
+		data.entryPoint = "Source/Main.lua";
+		configFile.root.addChild("entryPoint", "Source/Main.lua");
+	}
+	
+	if(configFile.root["defaultWidth"]) {	
+		data.defaultWidth = configFile.root["defaultWidth"]->intVal;
+	} else {
+		data.defaultWidth = 640;	
+		configFile.root.addChild("defaultWidth", 640);			
+	}
+	
+	if(configFile.root["defaultHeight"]) {	
+		data.defaultHeight = configFile.root["defaultHeight"]->intVal;
+	} else {
+		data.defaultHeight = 480;	
+		configFile.root.addChild("defaultHeight", 480);		
+	}
+
+	if(configFile.root["vSync"]) {	
+		data.vSync = configFile.root["vSync"]->boolVal;
+	} else {
+		data.vSync = false;
+		configFile.root.addChild("vSync", false);		
+	}
+
+
+	if(configFile.root["antiAliasingLevel"]) {
+		data.aaLevel = configFile.root["antiAliasingLevel"]->intVal;
+	} else {
+		data.aaLevel = 0;
+		configFile.root.addChild("antiAliasingLevel", 0);		
+	}
+
+
+	if(configFile.root["anisotropyLevel"]) {
+		data.anisotropy = configFile.root["anisotropyLevel"]->intVal;
+	} else {
+		data.anisotropy = 0;
+		configFile.root.addChild("anisotropyLevel", 0);		
+	}
+
+	if(configFile.root["frameRate"]) {
+		data.frameRate = configFile.root["frameRate"]->intVal;	
+	} else {
+		data.frameRate = 60;
+		configFile.root.addChild("frameRate", 60);
+	}
+	
+	data.modules.clear();
+	if(configFile.root["modules"]) {
+		for(int i=0; i < configFile.root["modules"]->length; i++) {
+			ObjectEntry *module = (*configFile.root["modules"])[i];
+			data.modules.push_back(module->stringVal);
+		}
+	}	
+
+	if(configFile.root["backgroundColor"]) {
+		ObjectEntry *color = configFile.root["backgroundColor"];
+		if((*color)["red"] && (*color)["green"] && (*color)["blue"]) {
+			data.backgroundColorR = (*color)["red"]->NumberVal;
+			data.backgroundColorG = (*color)["green"]->NumberVal;
+			data.backgroundColorB = (*color)["blue"]->NumberVal;
+		} else {
+			data.backgroundColorR = 0.0;
+			data.backgroundColorG = 0.0;
+			data.backgroundColorB = 0.0;
+			
+			ObjectEntry *color = configFile.root.addChild("backgroundColor");			
+			color->addChild("red", 0.0);
+			color->addChild("green", 0.0);
+			color->addChild("blue", 0.0);						
+		}
+	}
+
+	return true;
+}
+
+bool PolycodeProject::saveFile() {
+
+
+	configFile.root["frameRate"]->intVal = data.frameRate;
+	configFile.root["defaultWidth"]->intVal = data.defaultWidth;
+	configFile.root["defaultHeight"]->intVal = data.defaultHeight;
+	configFile.root["entryPoint"]->stringVal = data.entryPoint;
+	
+	ObjectEntry *color = configFile.root["backgroundColor"];
+	(*color)["red"]->NumberVal = data.backgroundColorR;
+	(*color)["green"]->NumberVal = data.backgroundColorG;
+	(*color)["blue"]->NumberVal = data.backgroundColorB;
+
+
+	if(configFile.root["modules"]) {
+		configFile.root["modules"]->Clear();
+	}
+	
+	for(int j=0; j < data.modules.size(); j++) {
+		if(!configFile.root["modules"]) {
+			configFile.root.addChild("modules");	
+		}		
+		configFile.root["modules"]->addChild("module", data.modules[j]);
+	}
+	
+	if(configFile.root["packedItems"]) {
+		configFile.root["packedItems"]->Clear();
+	}
+	
+	vector<OSFileEntry> files = OSBasics::parseFolder(projectFolder, false);
+
+	for(int i=0; i < files.size(); i++) {
+		OSFileEntry entry = files[i];
+		
+		if(!configFile.root["packedItems"]) {
+				configFile.root.addChild("packedItems");	
+		}
+		
+		if(entry.type == OSFileEntry::TYPE_FOLDER) {
+			ObjectEntry *objectEntry = configFile.root["packedItems"]->addChild("item");
+			objectEntry->addChild("type", "folder");
+			objectEntry->addChild("path", entry.name);			
+		} else {
+			if(entry.fullPath != projectFile) {
+				ObjectEntry *objectEntry = configFile.root["packedItems"]->addChild("item");
+				objectEntry->addChild("type", "file");
+				objectEntry->addChild("path", entry.name);
+			}
+		}
+	}
+
+	
+	unsigned int afMap[6] = {0,1,2,4,8,16};
+	unsigned int aaMap[4] = {0,2,4,6};
+		
+	configFile.root["antiAliasingLevel"]->intVal = data.aaLevel;
+	configFile.root["anisotropyLevel"]->intVal = data.anisotropy;
+	configFile.root["vSync"]->boolVal = data.vSync;
+	
+	configFile.saveToXML(projectFile);
+
+	return true;
 }
 
 PolycodeProject::~PolycodeProject() {

+ 0 - 1
IDE/Contents/Source/PolycodeProjectBrowser.cpp

@@ -125,7 +125,6 @@ bool PolycodeProjectBrowser::listHasFileEntry(vector<OSFileEntry> files, OSFileE
 }
 
 void PolycodeProjectBrowser::parseFolderIntoNode(UITree *node, String spath, PolycodeProject *parentProject) {
-	printf("Parsing %s\n", spath.c_str());
 	vector<OSFileEntry> files = OSBasics::parseFolder(spath, false);
 	
 	// check if files got deleted

+ 56 - 95
IDE/Contents/Source/PolycodeProjectEditor.cpp

@@ -22,8 +22,21 @@
  
 #include "PolycodeProjectEditor.h"
 #include "OSBasics.h"
+#include "PolycodeConsole.h"
 
-PolycodeProjectEditor::PolycodeProjectEditor() : PolycodeEditor(true){
+PolycodeProjectEditorFactory::PolycodeProjectEditorFactory(PolycodeProjectManager *projectManager) : PolycodeEditorFactory() {
+	this->projectManager = projectManager;
+	extensions.push_back("polyproject");
+}
+
+PolycodeEditor *PolycodeProjectEditorFactory::createEditor() {
+	PolycodeProjectEditor *editor = new PolycodeProjectEditor(projectManager);
+	return editor;
+}
+
+PolycodeProjectEditor::PolycodeProjectEditor(PolycodeProjectManager *projectManager) : PolycodeEditor(true){
+
+	this->projectManager = projectManager;
 
 	grid = new ScreenImage("editorGrid.png");
 	
@@ -158,87 +171,39 @@ PolycodeProjectEditor::~PolycodeProjectEditor() {
 	
 }
 
-bool PolycodeProjectEditor::openFile(OSFileEntry filePath) {
-
-
-	if(!configFile.loadFromXML(filePath.fullPath)) {
-		return false;
-	}
+bool PolycodeProjectEditor::openFile(OSFileEntry filePath) {	
 	
-	if(configFile.root["entryPoint"]) {	
-		entryPointInput->setText(configFile.root["entryPoint"]->stringVal);
-	} else {
-		configFile.root.addChild("entryPoint", "Source/Main.lua");		
-	}
-	
-	if(configFile.root["defaultWidth"]) {	
-		defaultWidthInput->setText(configFile.root["defaultWidth"]->stringVal);
-	} else {
-		configFile.root.addChild("defaultWidth", 640);	
+	associatedProject = projectManager->getProjectByProjectFile(filePath.fullPath);
+	if(!associatedProject) {
+		return false;
 	}
 	
-	if(configFile.root["defaultHeight"]) {		
-		defaultHeightInput->setText(configFile.root["defaultHeight"]->stringVal);
-	} else {
-		configFile.root.addChild("defaultHeight", 480);
-	}
-
-	if(configFile.root["vSync"]) {	
-		vSyncCheckBox->setChecked(configFile.root["vSync"]->boolVal);
-	} else {
-		configFile.root.addChild("vSync", false);
-	}
-
+	entryPointInput->setText(associatedProject->data.entryPoint);
+	defaultWidthInput->setText(String::IntToString(associatedProject->data.defaultWidth));
+	defaultHeightInput->setText(String::IntToString(associatedProject->data.defaultHeight));
+	vSyncCheckBox->setChecked(associatedProject->data.vSync);
 	
-
 	unsigned int aaMap[7] = {0,1,1,1,2,2,3};
-	if(configFile.root["antiAliasingLevel"]) {
-		aaLevelComboBox->setSelectedIndex(aaMap[configFile.root["antiAliasingLevel"]->intVal]);
-	} else {
-		aaLevelComboBox->setSelectedIndex(0);
-		configFile.root.addChild("antiAliasingLevel", 0);
-	}
+	aaLevelComboBox->setSelectedIndex(aaMap[associatedProject->data.aaLevel]);
 
 	unsigned int afMap[17] = {0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5};
-	if(configFile.root["anisotropyLevel"]) {
-		afLevelComboBox->setSelectedIndex(afMap[configFile.root["anisotropyLevel"]->intVal]);
-	} else {
-		afLevelComboBox->setSelectedIndex(0);
-		configFile.root.addChild("anisotropyLevel", 0);
-	}
-
-	if(configFile.root["frameRate"]) {
-		framerateInput->setText(configFile.root["frameRate"]->stringVal);	
-	} else {
-		configFile.root.addChild("frameRate", 60);	
-	}
-	
-	if(configFile.root["modules"]) {
-		for(int i=0; i < configFile.root["modules"]->length; i++) {
-			ObjectEntry *module = (*configFile.root["modules"])[i];
-			for(int j=0; j < moduleCheckboxes.size(); j++) {
-				if(moduleCheckboxes[j]->getCaptionLabel() == module->stringVal) {
-					moduleCheckboxes[j]->setChecked(true);
-				}
+	afLevelComboBox->setSelectedIndex(afMap[associatedProject->data.anisotropy]);
+	framerateInput->setText(String::IntToString(associatedProject->data.frameRate));	
+	
+	for(int i=0; i < associatedProject->data.modules.size(); i++) {
+		bool hasModule = false;
+		for(int j=0; j < moduleCheckboxes.size(); j++) {
+			if(moduleCheckboxes[j]->getCaptionLabel() == associatedProject->data.modules[i]) {
+				moduleCheckboxes[j]->setChecked(true);
+				hasModule = true;
 			}
-		}
-	}	
-
-	Number backgroundColorR, backgroundColorG, backgroundColorB;	
-	if(configFile.root["backgroundColor"]) {
-		ObjectEntry *color = configFile.root["backgroundColor"];
-		if((*color)["red"] && (*color)["green"] && (*color)["blue"]) {
-			backgroundColorR = (*color)["red"]->NumberVal;
-			backgroundColorG = (*color)["green"]->NumberVal;
-			backgroundColorB = (*color)["blue"]->NumberVal;
-			bgColorBox->setBoxColor(Color(backgroundColorR, backgroundColorG, backgroundColorB, 1.0));	
-		} else {
-			ObjectEntry *color = configFile.root.addChild("backgroundColor");
-			color->addChild("red", 0.0);
-			color->addChild("green", 0.0);
-			color->addChild("blue", 0.0);						
+		}	
+		if(!hasModule) {
+			PolycodeConsole::print("WARNING: MISSING MODULE: "+associatedProject->data.modules[i]);
 		}
 	}
+
+	bgColorBox->setBoxColor(Color(associatedProject->data.backgroundColorR, associatedProject->data.backgroundColorG, associatedProject->data.backgroundColorB, 1.0));	
 	
 	PolycodeEditor::openFile(filePath);	
 	return true;
@@ -249,40 +214,36 @@ void PolycodeProjectEditor::Resize(int x, int y) {
 	PolycodeEditor::Resize(x,y);	
 }
 
+
 void PolycodeProjectEditor::saveFile() {
 
-	configFile.root["frameRate"]->intVal = atoi(framerateInput->getText().c_str());
-	configFile.root["defaultWidth"]->intVal = atoi(defaultWidthInput->getText().c_str());
-	configFile.root["defaultHeight"]->intVal = atoi(defaultHeightInput->getText().c_str());	
-	configFile.root["entryPoint"]->stringVal = entryPointInput->getText();
-	
-	ObjectEntry *color = configFile.root["backgroundColor"];	
-	(*color)["red"]->NumberVal = bgColorBox->getSelectedColor().r;
-	(*color)["green"]->NumberVal = bgColorBox->getSelectedColor().g;
-	(*color)["blue"]->NumberVal = bgColorBox->getSelectedColor().b;
+	if(!associatedProject) {
+		return;
+	}
 
+	associatedProject->data.frameRate = atoi(framerateInput->getText().c_str());
+	associatedProject->data.defaultWidth = atoi(defaultWidthInput->getText().c_str());
+	associatedProject->data.defaultHeight = atoi(defaultHeightInput->getText().c_str());	
+	associatedProject->data.entryPoint = entryPointInput->getText();
+	
+	associatedProject->data.backgroundColorR = bgColorBox->getSelectedColor().r;
+	associatedProject->data.backgroundColorG = bgColorBox->getSelectedColor().g;
+	associatedProject->data.backgroundColorB = bgColorBox->getSelectedColor().b;		
 
-	if(configFile.root["modules"]) {
-		configFile.root["modules"]->Clear();
-	}
+	associatedProject->data.modules.clear();
 	
 	for(int j=0; j < moduleCheckboxes.size(); j++) {
 		if(moduleCheckboxes[j]->isChecked()) {
-			
-			if(!configFile.root["modules"]) {
-				configFile.root.addChild("modules");	
-			}
-		
-			configFile.root["modules"]->addChild("module", moduleCheckboxes[j]->getCaptionLabel());
+			associatedProject->data.modules.push_back(moduleCheckboxes[j]->getCaptionLabel());
 		}
 	}
-	
+		
 	unsigned int afMap[6] = {0,1,2,4,8,16};
 	unsigned int aaMap[4] = {0,2,4,6};
 		
-	configFile.root["antiAliasingLevel"]->intVal = aaMap[aaLevelComboBox->getSelectedIndex()];
-	configFile.root["anisotropyLevel"]->intVal = afMap[afLevelComboBox->getSelectedIndex()];
-	configFile.root["vSync"]->boolVal = vSyncCheckBox->isChecked();
+	associatedProject->data.aaLevel = aaMap[aaLevelComboBox->getSelectedIndex()];
+	associatedProject->data.anisotropy = afMap[afLevelComboBox->getSelectedIndex()];
+	associatedProject->data.vSync = vSyncCheckBox->isChecked();
 	
-	configFile.saveToXML(filePath);
+	associatedProject->saveFile();
 }

+ 14 - 3
IDE/Contents/Source/PolycodeProjectManager.cpp

@@ -45,9 +45,11 @@ PolycodeProject* PolycodeProjectManager::openProject(String path) {
 	
 	vector<String> bits = path.split("/");
 	
-	String projectPath = "";
-	for(int i=0; i < bits.size() - 1; i++) {
-		projectPath += "/"+bits[i];
+	String projectPath = bits[0];
+	if(bits.size() > 2) {
+		for(int i=1; i < bits.size() - 1; i++) {
+			projectPath += "/"+bits[i];
+		}
 	}
 	
 	vector<String> bits2 = bits[bits.size()-1].split(".");
@@ -76,6 +78,15 @@ int PolycodeProjectManager::removeProject(PolycodeProject *project) {
 	return 1;
 }
 
+PolycodeProject *PolycodeProjectManager::getProjectByProjectFile(String projectFile) {
+	for(int i=0; i < projects.size(); i++) {
+		if(projects[i]->getProjectFile() == projectFile) {
+			return projects[i];
+		}
+	}
+	return NULL;
+}
+
 void PolycodeProjectManager::createNewFile(String templatePath, String newFileName) {
 	if(activeFolder == "")
 		return;

+ 2 - 2
IDE/Contents/Source/PolycodeTextEditor.cpp

@@ -35,7 +35,7 @@ PolycodeSyntaxHighlighter::PolycodeSyntaxHighlighter(String extension) {
 //	String separators = " ;()\t\n=+-/\\'\"";	
 //	String keywords = "true,false,";
 	
-	separators = String("[ [ ] { } ; . , : ( ) \t \n = + - / \\ ' \"").split(" ");
+	separators = String("[ [ ] { } ; . , : # ( ) \t \n = + - / \\ ' \"").split(" ");
 	separators.push_back(" ");
 	
 	keywords = String("true false class self break do end else elseif function if local nil not or repeat return then until while").split(" ");
@@ -219,7 +219,7 @@ bool PolycodeTextEditor::openFile(OSFileEntry filePath) {
 	
 	Data *data = new Data();
 	data->loadFromFile(filePath.fullPath);	
-	textInput->insertText(data->getAsString(String::ENCODING_UTF8));
+	textInput->setText(data->getAsString(String::ENCODING_UTF8));
 	delete data;
 	
 	PolycodeEditor::openFile(filePath);

+ 4 - 0
IDE/Contents/Source/PolycodeToolLauncher.cpp

@@ -53,9 +53,13 @@ String PolycodeToolLauncher::generateTempPath() {
 }
 
 void PolycodeToolLauncher::buildProject(PolycodeProject *project, String destinationPath) {
+
+	project->saveFile();
+
 	String projectBasePath = project->getRootFolder();
 	String projectPath = project->getProjectFile();
 	
+	
 	String polycodeBasePath = CoreServices::getInstance()->getCore()->getDefaultWorkingDirectory();
 	
 	String command = "cd "+projectBasePath+" && "+polycodeBasePath+"/Standalone/Bin/polybuild  --config="+projectPath+" --out="+destinationPath;	

+ 1 - 1
Modules/Contents/UI/Include/PolyUIComboBox.h

@@ -42,7 +42,7 @@ namespace Polycode {
 			ScreenLabel *itemLabel;
 	};
 
-	class _PolyExport UIComboBox : public ScreenEntity {
+	class _PolyExport UIComboBox : public UIElement {
 		public:
 			UIComboBox(Number comboWidth);
 			~UIComboBox();

+ 4 - 0
Modules/Contents/UI/Include/PolyUITextInput.h

@@ -133,6 +133,8 @@ namespace Polycode {
 			ScreenShape *selectorRectBottom;		
 			int numLines;
 			
+			bool needFullRedraw;
+			
 			Number padding;
 			Number lineSpacing;
 		
@@ -141,6 +143,8 @@ namespace Polycode {
 			int selectionL;
 			int selectionR;		
 		
+			bool settingText;
+		
 			int selectionCaretPosition;
 			int selectionLine;
 		

+ 1 - 1
Modules/Contents/UI/Source/PolyUIComboBox.cpp

@@ -49,7 +49,7 @@ UIComboBoxItem::~UIComboBoxItem() {
 }
 
 
-UIComboBox::UIComboBox(Number comboWidth) : ScreenEntity() {
+UIComboBox::UIComboBox(Number comboWidth) : UIElement() {
 
 	isDroppedDown = false;
 	selectedIndex = -1;

+ 35 - 6
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -42,8 +42,11 @@ UITextInput::UITextInput(bool multiLine, Number width, Number height) : UIElemen
 	caretPosition = 0;
 	caretImagePosition = 0;
 	
+	settingText = false;
+	
 	currentLine = NULL;
 	
+	needFullRedraw = false;
 	
 	lineOffset = -1;
 	numLines = 0;
@@ -307,15 +310,37 @@ void UITextInput::deleteSelection() {
 }
 
 void UITextInput::changedText() {
-
-	if(syntaxHighliter) {
-		std::vector<SyntaxHighlightToken> tokens = syntaxHighliter->parseText(getText());
+	if(settingText)
+		return;
 		
-		for(int i=0; i < lines.size(); i++) {
+	if(syntaxHighliter && multiLine) {
+	
+		unsigned int startLine = (-linesContainer->getPosition().y) / (lineHeight+lineSpacing);				
+		unsigned int endLine = startLine + ((int)((height / (lineHeight+lineSpacing)))) + 1;					
+		
+		if(endLine > lines.size())
+			endLine = lines.size();
+	
+		if(needFullRedraw) {
+			startLine = 0;
+			endLine = lines.size();
+			needFullRedraw = false;
+		}
+	
+		String totalText = L"";
+		for(int i=startLine; i < endLine; i++) {
+				totalText += lines[i]->getText();					
+				if(i < lines.size()-1)
+					totalText += L"\n";
+		}	
+		
+		std::vector<SyntaxHighlightToken> tokens = syntaxHighliter->parseText(totalText);
+		
+		for(int i=startLine; i < endLine; i++) {
 			lines[i]->getLabel()->clearColors();
 		}
 		
-		int lineIndex = 0;
+		int lineIndex = startLine;
 		int rangeStart = 0;
 		int rangeEnd = 0;
 				
@@ -341,7 +366,7 @@ void UITextInput::changedText() {
 			}
 		}
 		
-		for(int i=0; i < lines.size(); i++) {
+		for(int i=startLine; i < endLine; i++) {
 			lines[i]->setText(lines[i]->getText());
 			lines[i]->setColor(1.0, 1.0, 1.0, 1.0);
 		}
@@ -434,6 +459,7 @@ void UITextInput::setText(String text) {
 		clearSelection();				
 		updateCaretPosition();		
 	} else {
+		needFullRedraw = true;	
 		selectAll();
 		insertText(text);
 		clearSelection();
@@ -629,6 +655,7 @@ void UITextInput::selectAll() {
 
 void UITextInput::insertText(String text) {	
 	vector<String> strings = text.split("\n");
+	settingText = true;
 
 	if(hasSelection)
 		deleteSelection();
@@ -662,6 +689,8 @@ void UITextInput::insertText(String text) {
 		currentLine->setText(ctext);			
 	}
 	
+	settingText = false;	
+	
 	changedText();
 	updateCaretPosition();		
 	restructLines();