Ejemplo n.º 1
0
        public void addSelectTexture(TerrainTextureButton but)
        {
            if (mSelectedButton != null)
            {
                mSelectedButton.Invalidate();
            }

            mSelectedButton = but;
            mSelectedButton.Invalidate();


            if (but is TerrainTextureSplatButton)
            {
                SelectedDef = SimTerrainType.getFromTypeName(but.typename);

                if (!isActiveSetSelected())
                {
                    TerrainGlobals.getTexturing().addActiveTexture(SimTerrainType.getWorkingTexName(mSelectedDef));
                }
            }
            else if (but is TerrainTextureDecalButton)
            {
                if (!isActiveSetSelected())
                {
                    TerrainGlobals.getTexturing().addActiveDecal(((TerrainTextureDecalButton)but).mFullFilename);
                }
                TerrainGlobals.getTerrainFrontEnd().SelectedDecalIndex = TerrainGlobals.getTexturing().getActiveDecalIndex(((TerrainTextureDecalButton)but).mFullFilename);
                if (TerrainGlobals.getEditor().getRenderMode() == BTerrainEditor.eEditorRenderMode.cRenderTextureSelectRender)
                {
                    TerrainGlobals.getTexturing().reloadCachedVisuals();
                }
            }
        }
Ejemplo n.º 2
0
        public void swapSelectTexture(TerrainTextureButton but)
        {
            if (mSelectedButton != but)
            {
                TerrainTextureDef newDef  = null;
                TerrainTextureDef origDef = mSelectedDef;
                bool activeSel            = isActiveSetSelected();
                if (activeSel)
                {
                    newDef = SimTerrainType.getFromTypeName(but.typename);
                }
                else
                {
                    addSelectTexture(but);
                    newDef = mSelectedDef;
                }

                //replace across the board
                if (mSelectSwap)
                {
                    TerrainGlobals.getTexturing().swapActiveTextures(SimTerrainType.getActiveSetIndex(origDef), SimTerrainType.getActiveSetIndex(newDef));
                    SimTerrainType.swapActiveSetDef(SimTerrainType.getActiveSetIndex(origDef), SimTerrainType.getActiveSetIndex(newDef));
                }
                else if (mSelectReplace)
                {
                    if (SimTerrainType.getActiveSetIndex(newDef) == 0)
                    {
                        MessageBox.Show("You can not replace with the base texture");
                    }
                    else
                    {
                        TerrainGlobals.getTexturing().replaceActiveTexture(SimTerrainType.getActiveSetIndex(origDef), SimTerrainType.getActiveSetIndex(newDef));
                        SimTerrainType.removeActiveSetDef(origDef);
                    }
                }

                if (!activeSel)
                {
                    //now select our new texture
                    addSelectTexture(but);
                }
            }
            mSelectSwap     = false;
            mSelectReplace  = false;
            alertLabel.Text = "";

            TerrainGlobals.getTexturing().freeAllCaches();
            selectActiveSet();
            redrawPreviewList(0);
            SelectButton(but);

            //TerrainGlobals.getTexturing().reloadActiveTextures(true);
        }
Ejemplo n.º 3
0
 public void SelectButton(TerrainTextureButton but)
 {
     if (but is TerrainTextureSplatButton)
     {
         if (mSelectSwap || mSelectReplace)
         {
             if (mSelectedButton is TerrainTextureSplatButton)
             {
                 swapSelectTexture(but);
             }
         }
         else
         {
             addSelectTexture(but);
             //show our properties window
             if (isActiveSetSelected())
             {
                 texturePropertiesPanel.Enabled = true;
                 setTextureProperties();
                 panel1.Refresh();
             }
             else
             {
                 texturePropertiesPanel.Enabled = false;
                 panel1.Refresh();
             }
             TerrainGlobals.getEditor().setMode(BTerrainEditor.eEditorMode.cModeTexEdit);
         }
     }
     else if (but is TerrainTextureDecalButton)
     {
         if (mSelectSwap || mSelectReplace)
         {
             return;
         }
         else
         {
             addSelectTexture(but);
             //TerrainGlobals.getEditor().setMode(BTerrainEditor.eEditorMode.cModeDecalEdit);
         }
     }
 }
Ejemplo n.º 4
0
        public void removeSelectedTexture()
        {
            if (mSelectedButton is TerrainTextureSplatButton)
            {
                if (TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex == 0)
                {
                    return;
                }

                if (SimTerrainType.mActiveWorkingSet.Count - 1 <= 0)
                {
                    return;
                }

                TerrainGlobals.getTexturing().removeActiveTexture(SimTerrainType.getActiveSetIndex(mSelectedDef));

                SimTerrainType.removeActiveSetDef(mSelectedDef);

                flowLayoutPanel1.Controls.Remove(mSelectedButton);
                SelectedDef = SimTerrainType.getDefsOfActiveSet()[0];
            }
            else
            {
                //   if (TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex == 0)
                //      return;

                int index = TerrainGlobals.getTexturing().getActiveDecalIndex(((TerrainTextureDecalButton)mSelectedButton).mFullFilename);
                TerrainGlobals.getTexturing().removeActiveDecal(index);


                flowLayoutPanel1.Controls.Remove(mSelectedButton);
                SelectedDef = SimTerrainType.getDefsOfActiveSet()[0];
            }
            redrawPreviewList(0);
            mSelectedButton = (TerrainTextureButton)flowLayoutPanel1.Controls[firstSplatIndex()];
        }