Преглед изворни кода

Fixed some property sheets, entity selection will now cycle through entities under cursor on repeated clicks

Ivan Safrin пре 12 година
родитељ
комит
5baf7dc815

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

@@ -35,10 +35,8 @@ class EntityEditorPropertyView : public UIElement {
         EntityEditorPropertyView();
         ~EntityEditorPropertyView();
     
-        void setEntity(Entity *entity);
-    
+        void setEntity(Entity *entity);    
         void handleEvent(Event *event);
-    
         void updateShaderOptions();
     
         void Resize(Number width, Number height);

+ 4 - 2
IDE/Contents/Include/PolycodeEntityEditor.h

@@ -104,14 +104,16 @@ class EntityEditorMainView : public UIElement {
     
 		protected:
     
-    
+            CoreInput *input;
 			
             int editorMode;
 			Entity *topBar;
 			UIRect *headerBg;
 				
+            unsigned int multiselectIndex;
 			std::vector<Entity*> selectedEntities;
-			
+            std::vector<Entity*> entitiesToSelect;
+    
 			Scene *mainScene;
             Entity *sceneObjectRoot;
     

+ 6 - 9
IDE/Contents/Source/EntityEditorPropertyView.cpp

@@ -97,7 +97,7 @@ void EntityEditorPropertyView::handleEvent(Event *event) {
 void EntityEditorPropertyView::updateShaderOptions() {
     SceneMesh *sceneMesh = dynamic_cast<SceneMesh*>(targetEntity);
     SceneLabel *sceneLabel = dynamic_cast<SceneLabel*>(targetEntity);
-    SceneSprite *sceneSprite = dynamic_cast<SceneSprite*>(sceneSprite);
+    SceneSprite *sceneSprite = dynamic_cast<SceneSprite*>(targetEntity);
     
     shaderTexturesSheet->enabled = false;
     shaderOptionsSheet->enabled = false;
@@ -106,9 +106,10 @@ void EntityEditorPropertyView::updateShaderOptions() {
         if(sceneMesh->getMaterial() && sceneMesh->getLocalShaderOptions()) {
             
             // can't edit the textures manually on a scene label or sprite
-//            if(!sceneLabel && !sceneSprite) {
+            if(!sceneLabel && !sceneSprite) {
             shaderTexturesSheet->setShader(sceneMesh->getMaterial()->getShader(0), sceneMesh->getMaterial(), sceneMesh->getLocalShaderOptions());
-  //          }
+                shaderTexturesSheet->enabled = true;
+            }
             
             shaderOptionsSheet->setShader(sceneMesh->getMaterial()->getShader(0), sceneMesh->getMaterial(), sceneMesh->getLocalShaderOptions());
         }
@@ -141,14 +142,10 @@ void EntityEditorPropertyView::setEntity(Entity *entity) {
     }
 
     SceneSound *sound = dynamic_cast<SceneSound*>(entity);
-    if(sound) {
-        soundSheet->setSound(sound);
-    }
+    soundSheet->setSound(sound);
 
     Camera *camera = dynamic_cast<Camera*>(entity);
-    if(camera) {
-        cameraSheet->setCamera(camera);
-    }
+    cameraSheet->setCamera(camera);
 
     SceneParticleEmitter *emitter = dynamic_cast<SceneParticleEmitter*>(entity);
     particleSheet->setParticleEmitter(emitter);

+ 17 - 5
IDE/Contents/Source/PolycodeEntityEditor.cpp

@@ -206,6 +206,7 @@ void CameraPreviewWindow::setCamera(Scene *scene, Camera *camera) {
 
 EntityEditorMainView::EntityEditorMainView() {
 	processInputEvents = true;
+    multiselectIndex = 0;
 
 	mainScene = new Scene(Scene::SCENE_3D, true);
 	renderTexture = new SceneRenderTexture(mainScene, mainScene->getDefaultCamera(), 512, 512);
@@ -238,7 +239,8 @@ EntityEditorMainView::EntityEditorMainView() {
 	
 	mainScene->getDefaultCamera()->setPosition(10, 10, 10);
 	mainScene->getDefaultCamera()->lookAt(Vector3());
-
+	mainScene->getDefaultCamera()->setClippingPlanes(0.01, 10000);
+    
 	grid = new EditorGrid();
 	mainScene->addChild(grid);
 	
@@ -268,6 +270,8 @@ EntityEditorMainView::EntityEditorMainView() {
     modeSwitchDropdown->addEventListener(this, UIEvent::CHANGE_EVENT);
     
     editorMode = EDITOR_MODE_3D;
+    
+    input = CoreServices::getInstance()->getCore()->getInput();
 }
 
 void EntityEditorMainView::setEditorMode(int newMode) {
@@ -301,6 +305,15 @@ Entity *EntityEditorMainView::getSelectedEntity() {
 
 void EntityEditorMainView::Update() {
     
+    if(entitiesToSelect.size() != 0) {
+        if(multiselectIndex > entitiesToSelect.size()-1) {
+            multiselectIndex = 0;
+        }
+        selectEntity(entitiesToSelect[multiselectIndex], input->getKeyState(KEY_LSHIFT) || input->getKeyState(KEY_RSHIFT));
+        multiselectIndex++;
+        entitiesToSelect.clear();
+    }
+    
     if(editorMode == EDITOR_MODE_2D) {
         Number aspect = renderTextureShape->getWidth() / renderTextureShape->getHeight();
         mainScene->getDefaultCamera()->setOrthoSize(trackballCamera->getCameraDistance() * aspect, trackballCamera->getCameraDistance());
@@ -438,9 +451,9 @@ void EntityEditorMainView::addEntityFromMenu(String command) {
     }
     
     if(command == "add_label") {
-        SceneLabel  *newLabel = new SceneLabel("TEXT", 12);
+        SceneLabel  *newLabel = new SceneLabel("TEXT", 12, "sans", Label::ANTIALIAS_FULL, 1.0);
         newLabel->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
-        newLabel->setAnchorPoint(-1.0, 0.0, 0.0);
+        newLabel->setAnchorPoint(0.0, 0.0, 0.0);
         newLabel->snapToPixels = false;
         newLabel->positionAtBaseline = false;
         sceneObjectRoot->addChild(newLabel);
@@ -454,7 +467,6 @@ void EntityEditorMainView::addEntityFromMenu(String command) {
     if(command == "add_light") {
         SceneLight *newLight = new SceneLight(SceneLight::POINT_LIGHT, mainScene, 1.0);
         newLight->bBox = Vector3(0.5, 0.5, 0.5);
-        mainScene->addLight(newLight);
         sceneObjectRoot->addChild(newLight);
         setEditorProps(newLight);
         newLight->setPosition(cursorPosition);
@@ -578,7 +590,7 @@ void EntityEditorMainView::handleEvent(Event *event) {
             CoreInput *input = CoreServices::getInstance()->getCore()->getInput();
             if(inputEvent->mouseButton == CoreInput::MOUSE_BUTTON2) {
                 Entity* targetEntity = (Entity*) event->getDispatcher();
-                selectEntity(targetEntity, input->getKeyState(KEY_LSHIFT) || input->getKeyState(KEY_RSHIFT));
+                entitiesToSelect.push_back(targetEntity);
             }
         }
     }