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

Entity property editing in 2D editor, fixed web docs header and footer

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

BIN
Assets/Icons/main_icon.png


+ 13 - 12
Core/Contents/Source/PolyScreen.cpp

@@ -142,31 +142,32 @@ void Screen::drawFilter() {
 	if(!filterShaderMaterial)
 		return;
 	
-	CoreServices::getInstance()->getRenderer()->bindFrameBufferTexture(originalSceneTexture);
+	Renderer *renderer = CoreServices::getInstance()->getRenderer();
+	
+	renderer->bindFrameBufferTexture(originalSceneTexture);
 	
 	Render();
-	CoreServices::getInstance()->getRenderer()->unbindFramebuffers();
+	renderer->unbindFramebuffers();
 	
 	ShaderBinding* materialBinding;		
 	for(int i=0; i < filterShaderMaterial->getNumShaders(); i++) {
 		materialBinding = filterShaderMaterial->getShaderBinding(i);
-		CoreServices::getInstance()->getRenderer()->applyMaterial(filterShaderMaterial, localShaderOptions[i], i);	
+		renderer->applyMaterial(filterShaderMaterial, localShaderOptions[i], i);	
 			
 		if(i==filterShaderMaterial->getNumShaders()-1) {
-			CoreServices::getInstance()->getRenderer()->loadIdentity();
-			CoreServices::getInstance()->getRenderer()->drawScreenQuad(CoreServices::getInstance()->getRenderer()->getXRes(), CoreServices::getInstance()->getRenderer()->getYRes());		
+			renderer->loadIdentity();
+			renderer->drawScreenQuad(renderer->getXRes(), renderer->getYRes());		
 		} else {
 			for(int j=0; j < materialBinding->getNumOutTargetBindings(); j++) {
-				CoreServices::getInstance()->getRenderer()->bindFrameBufferTexture(materialBinding->getOutTargetBinding(j)->texture);
+				renderer->bindFrameBufferTexture(materialBinding->getOutTargetBinding(j)->texture);
 				
-				CoreServices::getInstance()->getRenderer()->drawScreenQuad(materialBinding->getOutTargetBinding(j)->width, materialBinding->getOutTargetBinding(j)->height);
-				CoreServices::getInstance()->getRenderer()->unbindFramebuffers();
+				renderer->drawScreenQuad(materialBinding->getOutTargetBinding(j)->width, materialBinding->getOutTargetBinding(j)->height);
+				renderer->unbindFramebuffers();
 			}						
 		}
-		CoreServices::getInstance()->getRenderer()->clearShader();
-		CoreServices::getInstance()->getRenderer()->loadIdentity();
-		
-		CoreServices::getInstance()->getRenderer()->setOrthoMode();
+		renderer->clearShader();
+		renderer->loadIdentity();		
+		renderer->setOrthoMode();
 	}
 	
 }

+ 8 - 8
Documentation/Doxygen/base/footer.html

@@ -1,8 +1,8 @@
-              </div>
-              </div>
-               <div id="footer">
-		Polycode Framework. All content copyright Ivan Safrin, 2011.
-                </div>
-        </body>
-</html>
-
+	</div>	
+		</div>
+			<div id="footer">
+				Copyright Ivan Safrin, 2013
+			</div>
+		</div>
+	</body>
+</html>

+ 24 - 25
Documentation/Doxygen/base/header.html

@@ -1,13 +1,15 @@
 <html>
-        <head>  
-                <title>Polycode</title>
-                 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-                <link rel="stylesheet" type="text/css" media="screen" href="/css/main.css"/>
-                <link rel="stylesheet" type="text/css" media="screen" href="/css/docs.css"/>
-		<script type="text/javascript" src="/js/docs.js"></script> 
-		<script type="text/javascript" src="/js/jquery.js"></script> 
+  <head>  
+    <title>Polycode</title>
+     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <meta name="description" content="Polycode is a free, open-source, cross-platform framework for creative code. "/>
+    <meta name="keywords" content="2d,3d,opengl,framework,game,engine,creative,code,sound" />
+    <link href='http://fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'>
+    <link href="/css/prettify.css" type="text/css" rel="stylesheet" />
+    <script type="text/javascript" src="/js/prettify.js"></script>
+    <link rel="image_src" type="image/jpeg" href="http://www.polycode.org/img/icon-facebook.gif" />
+    <link rel="stylesheet" type="text/css" media="screen" href="/css/main.css"/>
 <script type="text/javascript">
-
   var _gaq = _gaq || [];
   _gaq.push(['_setAccount', 'UA-309912-5']);
   _gaq.push(['_trackPageview']);
@@ -19,22 +21,19 @@
   })();
 
 </script>
-        </head>
-        <body>
-                <div id="nav">
-                        <div id="nav_menu">
-			        <div class="menu_item"><a href="/">Cover</a></div>
-                                <div class="menu_item"><a href="/features">Features</a></div>
-                                <div class="menu_item"><a href="/gallery">Gallery</a></div>
-                                <div class="menu_item"><a href="/downloads">Downloads</a></div>
-                                <div class="menu_item"><a href="/modules">Modules</a></div>
-                                <div class="menu_item"><a href="/learning">Learning</a></div>
-                                <div class="menu_item"><a href="/docs">Documentation</a></div>
-                                <div class="menu_item"><a href="/forum">Forum</a></div>
-
-                        </div>
-                        <div id="nav_logo"></div>
-                </div>
-                <div id="content_pane">
+  </head>
+  <body onLoad="prettyPrint()">
+    <div id="content_pane">
+    <div id="nav">
+      <div id="nav_logo"><a href="/"><img src="/img/toplogo.png"/></a></div>
+      <div id="nav_menu">
+        <span class="menu_item"><a href="/features">FEATURES</a></span>
+        <span class="menu_item"><a href="/gallery">GALLERY</a></span>
+        <span class="menu_item"><a href="/download">DOWNLOAD</a></span>
+        <span class="menu_item"><a href="/learn">LEARN</a></span>
+        <span class="menu_item"><a href="/community">COMMUNITY</a></span>
+      </div>
+    </div>
+    <div id="page_content_main">
 		<div id="docs_page">
 			<div>

+ 32 - 0
IDE/Contents/Include/PolycodeProps.h

@@ -75,6 +75,21 @@ class NumberProp : public PropProp {
 		UITextInput *numberEntry;
 };
 
+
+class CustomProp : public PropProp {
+	public:
+		CustomProp(String key, String value);
+		~CustomProp();
+		void handleEvent(Event *event);
+		void set(String key, String val);
+		String getValue();
+		String getKey();
+				
+		UITextInput *keyEntry;
+		UITextInput *valueEntry;
+		UIImageButton *removeButton;
+};
+
 class StringProp : public PropProp {
 	public:
 		StringProp(String caption);
@@ -249,6 +264,22 @@ class EntitySheet : public PropSheet {
 		ComboProp *blendingProp;
 };
 
+class EntityPropSheet : public PropSheet {
+	public:
+		EntityPropSheet();		
+		void handleEvent(Event *event);
+		void Update();
+		void refreshProps();
+				
+		UIButton *addButton;
+		
+		Entity *entity;
+		Entity *lastEntity;
+		
+		int removeIndex;
+		
+};
+
 class ShapeSheet : public PropSheet {
 	public:
 		ShapeSheet();
@@ -439,6 +470,7 @@ class PropList : public UIElement {
 		~PropList();
 		
 		void updateProps();
+		void updateSize();
 		
 		void addPropSheet(PropSheet *sheet);
 		void handleEvent(Event *event);

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

@@ -172,6 +172,7 @@ class PolycodeScreenEditorMain : public UIElement {
 		ScreenImageSheet *imageSheet;
 		ScreenLabelSheet *labelSheet;
 		SoundSheet *soundSheet;
+		EntityPropSheet *entityPropSheet;
 		ScreenEntityInstanceSheet *instanceSheet;
 		ScreenSpriteSheet *spriteSheet;
 		ScreenParticleSheet *particleSheet;

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

@@ -31,7 +31,7 @@ ExportProjectWindow::ExportProjectWindow() : UIWindow(L"Publish Project", 400, 3
 	label->color.a = 0.4;	
 	label->setPosition(padding, 50);
 
-	projectLocationInput = new UITextInput(false, 430-(padding*2.0), 12);	
+	projectLocationInput = new UITextInput(false, 420-(padding*2.0), 12);	
 	addChild(projectLocationInput);
 	projectLocationInput->setPosition(padding, 80);
 
@@ -55,7 +55,7 @@ ExportProjectWindow::ExportProjectWindow() : UIWindow(L"Publish Project", 400, 3
 	addChild(winCheckBox);
 	winCheckBox->setPosition(padding, 205);
 
-	linCheckBox = new UICheckBox("Linux (Intel 64-bit)", false);
+	linCheckBox = new UICheckBox("Linux (Intel 32-bit)", false);
 	addChild(linCheckBox);
 	linCheckBox->setPosition(padding, 225);
 

+ 144 - 1
IDE/Contents/Source/PolycodeProps.cpp

@@ -68,7 +68,10 @@ void PropList::updateProps() {
 	for(int i=0; i < props.size(); i++) {
 		props[i]->Update();
 	}
-	
+	updateSize();
+}
+
+void PropList::updateSize() {
 	Resize(width, height);
 	scrollContainer->setScrollValue(0, 0);	
 }
@@ -272,6 +275,58 @@ Vector2Prop::~Vector2Prop() {
 
 }
 
+CustomProp::CustomProp(String key, String value) : PropProp("") {
+	keyEntry = new UITextInput(false, 120, 12);
+	keyEntry->setText(key);
+	keyEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
+	propContents->addChild(keyEntry);
+	keyEntry->setPosition(-90, 0);
+
+	valueEntry = new UITextInput(false, 120, 12);
+	valueEntry->setText(value);	
+	valueEntry->addEventListener(this, UIEvent::CHANGE_EVENT);
+	propContents->addChild(valueEntry);
+	valueEntry->setPosition(45, 0);
+	
+	removeButton = new UIImageButton("Images/remove_icon.png");
+	removeButton->addEventListener(this, UIEvent::CLICK_EVENT);	
+	propContents->addChild(removeButton);
+	removeButton->setPosition(-110, 6);
+	
+	setHeight(30);
+
+}
+
+CustomProp::~CustomProp() {
+
+}
+
+void CustomProp::handleEvent(Event *event) {
+
+	if(event->getEventType() == "UIEvent") {
+	
+		if(event->getDispatcher() == keyEntry || event->getDispatcher() == valueEntry) {
+			dispatchEvent(new Event(), Event::CHANGE_EVENT);		
+		}	
+	
+		if(event->getDispatcher() == removeButton) {
+			dispatchEvent(new Event(), Event::CANCEL_EVENT);
+		}
+	}
+}
+
+void CustomProp::set(String key, String val) {
+}
+
+String CustomProp::getValue() {
+	return valueEntry->getText();
+}
+
+String CustomProp::getKey() {
+	return keyEntry->getText();
+}
+
+
 StringProp::StringProp(String caption) : PropProp(caption) {
 
 	stringEntry = new UITextInput(false, 150, 12);
@@ -894,6 +949,94 @@ void ShapeSheet::Update() {
 	}
 }
 
+EntityPropSheet::EntityPropSheet() : PropSheet("CUSTOM PROPERTIES", "entityProps"){
+
+	propHeight = 75;
+	
+	addButton = new UIButton("Add Property", 150);
+	addButton->addEventListener(this, UIEvent::CLICK_EVENT);
+	addChild(addButton);
+	addButton->setPosition(15, 35);
+	
+	entity = NULL;
+	lastEntity = NULL;
+	
+	removeIndex = -1;
+}
+
+void EntityPropSheet::handleEvent(Event *event) {
+	if(!entity)
+		return;
+		
+	if(event->getDispatcher() == addButton && event->getEventType() == "UIEvent") {
+		entity->entityProps.push_back(EntityProp());
+		refreshProps();
+	}
+	
+	for(int i=0; i < props.size(); i++) {
+		if(event->getDispatcher() == props[i] && event->getEventType() == "") {
+			switch(event->getEventCode()) {						
+				case Event::CANCEL_EVENT:
+					removeIndex = i;
+				break;
+				case Event::CHANGE_EVENT:
+					if(i < entity->entityProps.size()) {
+						entity->entityProps[i].propName = ((CustomProp*)props[i])->getKey();
+						entity->entityProps[i].propValue = ((CustomProp*)props[i])->getValue();			
+					}
+				break;				
+			}
+		}
+	}
+
+}
+
+void EntityPropSheet::refreshProps() {
+
+	for(int i=0; i < props.size(); i++) {
+		contents->removeChild(props[i]);
+		props[i]->removeAllHandlersForListener(this);
+		delete props[i];
+	}
+	props.clear();
+	propHeight = 75;
+	
+	for(int i=0; i < entity->entityProps.size(); i++) {			
+		EntityProp prop = entity->entityProps[i];
+		CustomProp *newProp = new CustomProp(prop.propName, prop.propValue);
+		newProp->addEventListener(this, Event::CANCEL_EVENT);
+		newProp->addEventListener(this, Event::CHANGE_EVENT);		
+		addProp(newProp);
+		propHeight += 35;
+	}
+	
+	addButton->setPosition(15, propHeight-40);	
+	dispatchEvent(new Event(), Event::CHANGE_EVENT);
+	Resize(width, height);	
+}
+
+void EntityPropSheet::Update() {
+	if(entity) {
+	
+		if(removeIndex != -1) {
+			if(removeIndex < entity->entityProps.size()) {
+				entity->entityProps.erase(entity->entityProps.begin() + removeIndex);
+			}
+			removeIndex = -1;
+			refreshProps();
+		}
+	
+		enabled = true;		
+		if(entity != lastEntity) {
+			refreshProps();
+			lastEntity = entity;
+		}
+	} else {
+		enabled = false;		
+	}
+}
+
+
 EntitySheet::EntitySheet() : PropSheet("ENTITY", "entity"){
 	idProp = new StringProp("ID");
 	addProp(idProp);

+ 11 - 2
IDE/Contents/Source/PolycodeScreenEditor.cpp

@@ -725,6 +725,10 @@ PolycodeScreenEditorMain::PolycodeScreenEditorMain() {
 	entitySheet = new EntitySheet();
 	entityProps->addPropSheet(entitySheet);
 	
+	entityPropSheet = new EntityPropSheet();
+	entityPropSheet->addEventListener(this, Event::CHANGE_EVENT);	
+	entityProps->addPropSheet(entityPropSheet);	
+	
 	selectEntity(NULL);	
 	
 	entityProps->updateProps();		
@@ -1499,6 +1503,7 @@ void PolycodeScreenEditorMain::selectEntity(ScreenEntity *entity) {
 	instanceSheet->instance = NULL;
 	particleSheet->emitter = NULL;
 	spriteSheet->sprite = NULL;
+	entityPropSheet->entity = NULL;
 				
 	if(!entity) {
 		selectedEntity = NULL;
@@ -1529,7 +1534,8 @@ void PolycodeScreenEditorMain::selectEntity(ScreenEntity *entity) {
 	}
 	
 	if(entity->getEntityProp("editor_type") != "root") {
-		entitySheet->entity = entity;	
+		entitySheet->entity = entity;
+		entityPropSheet->entity = entity;
 	}
 
 	if(dynamic_cast<ScreenParticleEmitter*>(entity)) {
@@ -1656,6 +1662,10 @@ void PolycodeScreenEditorMain::handleEvent(Event *event) {
 
 		
 	}
+
+	if(event->getDispatcher() == entityPropSheet) {
+			entityProps->updateSize();
+	}
 	
 	if((event->getDispatcher() == transform2dSheet || event->getDispatcher() == labelSheet || event->getDispatcher() == imageSheet) && event->getEventType() == "") {
 		syncTransformToSelected();
@@ -1664,7 +1674,6 @@ void PolycodeScreenEditorMain::handleEvent(Event *event) {
 	
 	if(event->getDispatcher() == CoreServices::getInstance()->getCore()->getInput()) {
 		if(event->getEventCode() == InputEvent::EVENT_KEYDOWN) {
-			printf("KEY: %d\n", inputEvent->key);
 			switch(inputEvent->key) {
 				case Polycode::KEY_ESCAPE:
 					if(selectedEntity) {