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

Fixed Unicode text rendering, fixed ortho not chaning size if it's been set, new about dialog in IDE, minor IDE tweaks

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

+ 3 - 1
Core/Contents/Source/PolyFont.cpp

@@ -50,7 +50,9 @@ Font::Font(const String& fileName) {
 			valid = false;
 		}
 	
-		FT_Select_Charmap(ftFace, FT_ENCODING_UNICODE);	
+		if(FT_Select_Charmap(ftFace, ft_encoding_unicode) != 0) {
+			printf("Warning font does not support unicode (%s)\n", fileName.c_str());
+		}
 		loaded = true;
 	} else {
 		Logger::log("Invalid font file specified (%s)\n", fileName.c_str());	

+ 10 - 12
Core/Contents/Source/PolyGLRenderer.cpp

@@ -506,20 +506,18 @@ void OpenGLRenderer::setOrthoMode(Number xSize, Number ySize, bool centered) {
 		ySize = yRes;
 		
 	setBlendingMode(BLEND_MODE_NORMAL);
-	if(!orthoMode) {
-		glDisable(GL_LIGHTING);
-		glMatrixMode(GL_PROJECTION);
-		glDisable(GL_CULL_FACE);
-		glPushMatrix();
-		glLoadIdentity();
+	glDisable(GL_LIGHTING);
+	glMatrixMode(GL_PROJECTION);
+	glDisable(GL_CULL_FACE);
+	glPushMatrix();
+	glLoadIdentity();
 		
-		if(centered) {
-			glOrtho(-xSize*0.5,xSize*0.5,ySize*0.5,-ySize*0.5,-1.0f,1.0f);		
-		} else {
-			glOrtho(0.0f,xSize,ySize,0,-1.0f,1.0f);
-		}
-		orthoMode = true;
+	if(centered) {
+		glOrtho(-xSize*0.5,xSize*0.5,ySize*0.5,-ySize*0.5,-1.0f,1.0f);		
+	} else {
+		glOrtho(0.0f,xSize,ySize,0,-1.0f,1.0f);
 	}
+	orthoMode = true;
 	glMatrixMode(GL_MODELVIEW);	
 	glLoadIdentity();
 }

+ 6 - 4
Core/Contents/Source/PolyLabel.cpp

@@ -211,8 +211,10 @@ Color Label::getColorForIndex(unsigned int index) {
 
 void Label::precacheGlyphs(String text, GlyphData *glyphData) {
 	glyphData->clearData();
+	
+	std::wstring wstr = std::wstring(text.getWDataWithEncoding(String::ENCODING_UTF8));
 		
-	int num_chars = text.length();
+	int num_chars = wstr.length();
 		
 		
 	glyphData->glyphs = (FT_Glyph*) malloc(sizeof(FT_Glyph) * num_chars);
@@ -238,11 +240,11 @@ void Label::precacheGlyphs(String text, GlyphData *glyphData) {
 	
 	int advanceMultiplier;
 	for(int n = 0; n < num_chars; n++ ) {
-		if(text[n] == '\t') {
+		if(wstr[n] == '\t') {
 			glyph_index = FT_Get_Char_Index(face, ' ');		
 			advanceMultiplier = 4;			
 		} else {
-			glyph_index = FT_Get_Char_Index(face, (FT_ULong)text[n]);		
+			glyph_index = FT_Get_Char_Index(face, (FT_ULong)wstr[n]);
 			advanceMultiplier = 1;
 		}
 
@@ -275,7 +277,7 @@ void Label::precacheGlyphs(String text, GlyphData *glyphData) {
 			continue;
 		}
 		
-		if(n == num_chars-1 && (text[n] == ' ' || text[n] == '\t')) {
+		if(n == num_chars-1 && (wstr[n] == ' ' || wstr[n] == '\t')) {
 			glyphData->trailingAdvance = (slot->advance.x >> 6) * advanceMultiplier;
 		}
 

+ 17 - 9
IDE/Build/Mac OS X/English.lproj/MainMenu.xib

@@ -677,6 +677,7 @@
 							<string key="NSFrameSize">{800, 600}</string>
 							<reference key="NSSuperview" ref="439893737"/>
 							<reference key="NSWindow"/>
+							<reference key="NSNextKeyView"/>
 							<object class="NSOpenGLPixelFormat" key="NSPixelFormat">
 								<object class="NSMutableData" key="NSPixelAttributes">
 									<bytes key="NS.bytes">AAAAYAAAAAA</bytes>
@@ -787,14 +788,6 @@
 					</object>
 					<int key="connectionID">449</int>
 				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">orderFrontStandardAboutPanel:</string>
-						<reference key="source" ref="1021"/>
-						<reference key="destination" ref="238522557"/>
-					</object>
-					<int key="connectionID">142</int>
-				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">delegate</string>
@@ -1131,6 +1124,14 @@
 					</object>
 					<int key="connectionID">592</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">showAbout:</string>
+						<reference key="source" ref="976324537"/>
+						<reference key="destination" ref="238522557"/>
+					</object>
+					<int key="connectionID">593</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
@@ -1896,7 +1897,7 @@
 				<reference key="dict.values" ref="0"/>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">592</int>
+			<int key="maxID">593</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1922,6 +1923,7 @@
 							<string>renameFile:</string>
 							<string>runProject:</string>
 							<string>saveFile:</string>
+							<string>showAbout:</string>
 						</object>
 						<object class="NSArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1939,6 +1941,7 @@
 							<string>id</string>
 							<string>id</string>
 							<string>id</string>
+							<string>id</string>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="actionInfosByName">
@@ -1959,6 +1962,7 @@
 							<string>renameFile:</string>
 							<string>runProject:</string>
 							<string>saveFile:</string>
+							<string>showAbout:</string>
 						</object>
 						<object class="NSArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
@@ -2018,6 +2022,10 @@
 								<string key="name">saveFile:</string>
 								<string key="candidateClassName">id</string>
 							</object>
+							<object class="IBActionInfo">
+								<string key="name">showAbout:</string>
+								<string key="candidateClassName">id</string>
+							</object>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="outlets">

+ 1 - 0
IDE/Build/Mac OS X/PolycodeAppDelegate.h

@@ -67,4 +67,5 @@ public:
 -(IBAction) saveFile: (id) sender;
 -(IBAction) findText: (id) sender;
 -(IBAction) openDocs: (id) sender;
+-(IBAction) showAbout: (id) sender;
 @end

+ 4 - 0
IDE/Build/Mac OS X/PolycodeAppDelegate.m

@@ -150,4 +150,8 @@
 	app->openDocs();
 }
 
+-(IBAction) showAbout: (id) sender {
+	app->showAbout();
+}
+
 @end

+ 3 - 1
IDE/Contents/Include/PolycodeFrame.h

@@ -202,7 +202,9 @@ public:
 	UIElement *modalRoot;
 	UIElement *fileBrowserRoot;
 	UIFileDialog *fileDialog;
-
+	
+	UIWindow *aboutWindow;
+	UIButton *aboutOKButton;
 private:
 	
 	int frameSizeX;

+ 1 - 0
IDE/Contents/Include/PolycodeIDEApp.h

@@ -72,6 +72,7 @@ public:
 	void browseExamples();
 	void newProject();
 	void newFile();
+	void showAbout();
 	
 	void openDocs();
 	

BIN
IDE/Contents/Resources/Images/about.png


+ 20 - 0
IDE/Contents/Source/PolycodeFrame.cpp

@@ -589,6 +589,22 @@ PolycodeFrame::PolycodeFrame() : ScreenEntity() {
 	yesNoPopup = new YesNoPopup();
 	yesNoPopup->visible = false;
 	
+	aboutWindow = new UIWindow("", 800, 440);
+	aboutWindow->closeOnEscape = true;
+	ScreenImage *aboutImage = new ScreenImage("Images/about.png");
+	aboutWindow->addChild(aboutImage);
+	aboutImage->setPosition(20, 40);
+	aboutWindow->visible = false;
+	aboutOKButton = new UIButton("OK", 100);
+	aboutWindow->addChild(aboutOKButton);
+	aboutOKButton->setPosition(700, 420);
+	aboutOKButton->addEventListener(this, UIEvent::CLICK_EVENT);
+	
+	ScreenLabel *versionLabel = new ScreenLabel("version 0.8.2", 12, "mono");
+	aboutWindow->addChild(versionLabel);
+	versionLabel->setPosition(20, 430);
+	versionLabel->color.a = 0.4;
+	
 	isDragging  = false;
 	dragLabel = new ScreenLabel("NONE", 11, "sans");
 	dragLabel->setPosition(0,-15);
@@ -712,6 +728,10 @@ void PolycodeFrame::showAssetBrowser(std::vector<String> extensions) {
 
 void PolycodeFrame::handleEvent(Event *event) {
 	
+	if(event->getDispatcher() == aboutOKButton && event->getEventType() == "UIEvent") {
+		hideModal();
+	}
+	
 	if(event->getDispatcher() == fileDialog && event->getEventType() == "UIEvent") {
 		fileBrowserRoot->removeChild(fileDialog);
 		fileDialogBlocker->visible = false;

+ 5 - 1
IDE/Contents/Source/PolycodeIDEApp.cpp

@@ -152,7 +152,7 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() {
 #else
 	menuBar = NULL;
 #endif
-	core->setVideoMode(1100, 700, false, false, 0, 0);
+	core->setVideoMode(1100, 700, false, true, 0, 0);
 
 
 }
@@ -166,6 +166,10 @@ void PolycodeIDEApp::renameFile() {
 	}
 }
 
+void PolycodeIDEApp::showAbout() {
+	frame->showModal(frame->aboutWindow);
+}
+
 void PolycodeIDEApp::doRemoveFile() {
 	if(projectManager->selectedFile != "") {
 		core->removeDiskItem(projectManager->selectedFile);

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

@@ -48,7 +48,7 @@ ProjectFontEntry::ProjectFontEntry(String fontPath, String fontName) : UIElement
 	removeButton->addEventListener(this, UIEvent::CLICK_EVENT);
 	addChild(removeButton);
 
-	fontNameInput = new UITextInput(false, 100, 23);
+	fontNameInput = new UITextInput(false, 100, 13);
 	fontNameInput->setText(fontName);
 	fontNameInput->setPosition(20, 0);
 	fontNameInput->addEventListener(this, UIEvent::CHANGE_EVENT);
@@ -59,7 +59,7 @@ ProjectFontEntry::ProjectFontEntry(String fontPath, String fontName) : UIElement
 	fontFileLabel = new ScreenLabel(entry.name, 12);
 	fontFileLabel->color.a = 0.6;
 	addChild(fontFileLabel);
-	fontFileLabel->setPosition(130, 6);
+	fontFileLabel->setPosition(140, 3);
 	
 	CoreServices::getInstance()->getFontManager()->registerFont(fontName, fontPath);
 }

+ 3 - 0
IDE/Contents/Source/PolycodeScreenEditor.cpp

@@ -1615,6 +1615,9 @@ void PolycodeScreenEditorMain::handleEvent(Event *event) {
 						if(selectedEntity->hasFocus) {
 							selectedEntity->ownsChildren = true;
 							selectedEntity->getParentEntity()->removeChild(selectedEntity);
+							if(selectedEntity == currentLayer) {
+								currentLayer = NULL;
+							}							
 							delete selectedEntity;
 							selectEntity(NULL);							
 							

+ 0 - 1
Player/Contents/Source/PolycodePlayer.cpp

@@ -868,7 +868,6 @@ void PolycodePlayer::handleEvent(Event *event) {
 
 bool PolycodePlayer::Update() {
 	if(L) {
-		lua_settop(L, 0);
 		if(doCodeInject) {
 			printf("INJECTING CODE:[%s]\n", injectCodeString.c_str());
 			doCodeInject = false;