コード例 #1
0
        void OnGUI()
        {
            if (m_autoTileset == null || m_autoTileset.AtlasTexture == null)
            {
                Close();
                if (m_autoTileset != null)
                {
                    EditorGUIUtility.PingObject(m_autoTileset);
                    Selection.activeObject = m_autoTileset;
                }
            }
            else
            {
                string[] editModeNames = System.Enum.GetNames(typeof(eEditMode));
                m_editMode = (eEditMode)GUILayout.Toolbar((int)m_editMode, editModeNames);
                bool isFirstUpdate = m_editMode != m_prevEditMode;
                switch (m_editMode)
                {
                    case eEditMode.TilesetAtlas: OnGUI_TilesetAtlas(isFirstUpdate); break;
                    case eEditMode.Collisions: OnGUI_Collisions(isFirstUpdate); break;
                    case eEditMode.ChangeTileset: OnGUI_ChangeTileset(isFirstUpdate); break;
                }
                m_prevEditMode = m_editMode;
            }

            if (GUI.changed)
            {
                m_autoTileset.BuildSubTilesetsList();
                EditorUtility.SetDirty(m_autoTileset);
            }
        }
コード例 #2
0
ファイル: cLight.cs プロジェクト: whztt07/HPL1Engine
		public override void Draw(Graphics aGfx,int alWorldX,int alWorldY ,eEditMode mMode, bool abSelected)
		{
			Color Col;
			
			if(mMode == eEditMode.Lights)
			{
				Col = abSelected?Color.FromArgb(80,255,80):Color.FromArgb(255,0,255);
				
				SolidBrush CenterBrush = new SolidBrush(Col);
				aGfx.FillEllipse(CenterBrush,mlX-10-alWorldX,mlY-10-alWorldY,
					20,20);
				CenterBrush.Dispose();
			}
			else
			{
				Col = Color.Gray;
				SolidBrush CenterBrush = new SolidBrush(Col);
				aGfx.FillEllipse(CenterBrush,mlX-3-alWorldX,mlY-3-alWorldY,
					6,6);
				CenterBrush.Dispose();
			}


            Pen OuterPen = new Pen(Col);
			aGfx.DrawEllipse(OuterPen,mlX-mfRadius-alWorldX,mlY-mfRadius-alWorldY,
							mfRadius*2,mfRadius*2);
			OuterPen.Dispose();
		}
コード例 #3
0
 public static void ShowDialog(AutoTileset _autoTileset, eEditMode mode = eEditMode.TilesetAtlas)
 {
     AutoTilesetEditorWindow window = (AutoTilesetEditorWindow)EditorWindow.GetWindow (typeof (AutoTilesetEditorWindow));
     window.m_editMode = mode;
     window.m_autoTileset = _autoTileset;
     window.wantsMouseMove = true;
 }
コード例 #4
0
ファイル: cImageEntity.cs プロジェクト: whztt07/HPL1Engine
		public override void Draw(Graphics aGfx,int alWorldX,int alWorldY ,eEditMode mMode, bool abSelected)
		{
			Image Pic;
			Matrix Mtx = new Matrix();
			
			PointF vRotPoint = new PointF((float)mlX- alWorldX, (float)mlY- alWorldY);
			
			float fAngle = mfAngle;
			if(mbFlipH) fAngle = 360 - fAngle;
			if(mbFlipV) fAngle = 360 - fAngle;
			
			Mtx.RotateAt(fAngle,vRotPoint, MatrixOrder.Append);

			PointF[] vPoints = new PointF[4];

			aGfx.Transform = Mtx;
			
			if(mbFlipH) mEntityData.mImage.RotateFlip(RotateFlipType.RotateNoneFlipX);
			if(mbFlipV) mEntityData.mImage.RotateFlip(RotateFlipType.RotateNoneFlipY);

			if(mEntityData.mlFrames<0){
				Pic = mEntityData.mImage;
			}
			else
			{
				cEntityAnimation Anim = (cEntityAnimation)mEntityData.mlstAnimations[mlAnimNum];
				int lFrame = (int)Anim.mlstAnimData[0];
				Pic = mEntityData.mvFrameImages[lFrame];
			}
			
			
			/*ImageAttributes Attrib = new ImageAttributes();
			Attrib.SetColorKey(Color.FromArgb(0,Color.FromArgb(0,0,0)),
								Color.FromArgb(0,Color.FromArgb(1,1,1)));*/

						
			aGfx.DrawImage(Pic,mlX - alWorldX - (int)mfWidth/2,
								mlY - alWorldY - (int)mfHeight/2,
								(int)mfWidth, (int)mfHeight);
							
			if(mbFlipH) mEntityData.mImage.RotateFlip(RotateFlipType.RotateNoneFlipX);
			if(mbFlipV) mEntityData.mImage.RotateFlip(RotateFlipType.RotateNoneFlipY);
			
			if(mMode == eEditMode.Props)
			{
				Pen RectPen;
				if(abSelected)RectPen = new Pen(Color.FromArgb(150,255,150));
				else RectPen = new Pen(Color.FromArgb(255,0,255));
				
				aGfx.DrawRectangle(RectPen,mlX - alWorldX - (int)mfWidth/2,
									mlY - alWorldY - (int)mfHeight/2,
									(int)mfWidth,(int)mfHeight);
			}

			Mtx.Reset();
			aGfx.Transform = Mtx;
		}
コード例 #5
0
ファイル: cSoundSource.cs プロジェクト: whztt07/HPL1Engine
		public override void Draw(Graphics aGfx,int alWorldX,int alWorldY ,eEditMode mMode, bool abSelected)
		{
			Color Col;
			
			if(mMode == eEditMode.SoundSource)
			{
				Col = abSelected?Color.FromArgb(80,255,80):Color.FromArgb(255,0,255);
				
				SolidBrush CenterBrush = new SolidBrush(Col);
				aGfx.FillEllipse(CenterBrush,mlX-10-alWorldX,mlY-10-alWorldY,
					20,20);
				
				string sText = msSoundName==""? "-None-" : msSoundName;
				
				Font tfont = new Font("Arial",8);
				
				aGfx.DrawString(sText,tfont,CenterBrush,mlX-mfCircleSize-alWorldX,
								mlY+mfCircleSize-alWorldY);
				
				tfont.Dispose();

				CenterBrush.Dispose();
			}
			else
			{
				Col = Color.Gray;
				SolidBrush CenterBrush = new SolidBrush(Col);
				aGfx.FillEllipse(CenterBrush,mlX-10-alWorldX,mlY-10-alWorldY,
					20,20);
				CenterBrush.Dispose();
			}

			Pen OuterPen = new Pen(Col);
			aGfx.DrawEllipse(OuterPen,mlX-mfCircleSize-alWorldX,mlY-mfCircleSize-alWorldY,
				mfCircleSize*2,mfCircleSize*2);
			OuterPen.Dispose();
		}
コード例 #6
0
ファイル: cArea.cs プロジェクト: whztt07/HPL1Engine
		public override void Draw(Graphics aGfx,int alWorldX,int alWorldY ,eEditMode mMode, bool abSelected)
		{
			Color Col;
			
			if(mMode == eEditMode.Area)
			{
				Col = abSelected?Color.FromArgb(80,255,80):Color.FromArgb(255,0,255);
				
				SolidBrush CenterBrush = new SolidBrush(Col);
				aGfx.FillEllipse(CenterBrush,mlX-5-alWorldX,mlY-5-alWorldY,
					10,10);

				string sText = ((cAreaType)mAForm.mlstTypes[mlTypeNum]).msName;
				
				Font tfont = new Font("Arial",8);
				
				aGfx.DrawString(sText,tfont,CenterBrush,mlX-alWorldX-(5*(sText.Length/2)),
					mlY-alWorldY+5);
				
				tfont.Dispose();
				
				CenterBrush.Dispose();
			}
			else
			{
				Col = Color.Gray;
				SolidBrush CenterBrush = new SolidBrush(Col);
				aGfx.FillEllipse(CenterBrush,mlX-5-alWorldX,mlY-5-alWorldY,
					10,10);
				CenterBrush.Dispose();
			}

			Pen OuterPen = new Pen(Col);
			aGfx.DrawRectangle(OuterPen,mlX-mfWidth/2-alWorldX,mlY-mfHeight/2-alWorldY,
				mfWidth,mfHeight);
			OuterPen.Dispose();
		}
コード例 #7
0
        void OnGUI_ChangeTileset(bool isFirstUpdate)
        {
            GUILayout.Label("Sub Tileset Configuration", EditorStyles.boldLabel);
            GUILayout.Space(20);
            GUILayout.Label("Tile Size: "+m_autoTileset.TileWidth);
            m_changeTilesetScrollPos = GUILayout.BeginScrollView(m_changeTilesetScrollPos);

            if (m_editAtlasSlot == null || m_editAtlasSlot.SubTilesets.Count == 0)
            {
                EditorGUILayout.HelpBox("There is no tileset selected! Go to TilesetAtlas tab, press Edit Tileset button and select a tileset to be edited.", MessageType.Warning);
                if (GUILayout.Button("Cancel"))
                {
                    m_editMode = eEditMode.TilesetAtlas;
                    if( m_clearSlotOnCancel )
                    {
                        m_clearSlotOnCancel = false;
                        m_editAtlasSlot.SubTilesets.Clear();
                    }
                }
            }
            else
            {
                GUILayout.Space(20);
                if (GUILayout.Button("Accept", GUILayout.Height(25)))
                {
                    if (_validateTilesetTextures(m_editAtlasSlot))
                    {
                        foreach (SubTilesetConf tilesetConf in m_editAtlasSlot.SubTilesets)
                        {
                            UtilsAutoTileMap.CopySubTilesetInAtlas(m_autoTileset, tilesetConf);
                        }
                        m_autoTileset.AtlasTexture.Apply();
                        SaveTextureAsset(m_autoTileset.AtlasTexture);
                        m_autoTileset.GenerateAutoTileData();
                        EditorUtility.SetDirty(m_autoTileset);
                        m_editMode = eEditMode.TilesetAtlas;
                    }
                }
                GUILayout.Space(20);
                if (GUILayout.Button("Cancel", GUILayout.Height(25)))
                {
                    m_editMode = eEditMode.TilesetAtlas;
                    if (m_clearSlotOnCancel)
                    {
                        m_clearSlotOnCancel = false;
                        m_editAtlasSlot.SubTilesets.Clear();
                    }
                }
                GUILayout.Space(20);

                EditorGUILayout.BeginVertical(GUILayout.MinWidth(300));
                if (m_editAtlasSlot.SubTilesets.Count == 1)
                { // if it is an autotile tilesets, it's made of 5 textures
                    for (int i = 0; i < m_editAtlasSlot.SubTilesets[0].SourceTexture.Length; ++i)
                    {
                        EditorGUILayout.LabelField(_GetSrcTextureName(i, m_editAtlasSlot.SubTilesets[0].HasAutotiles));
                        m_editAtlasSlot.SubTilesets[0].SourceTexture[i] = EditorGUILayout.ObjectField(m_editAtlasSlot.SubTilesets[0].SourceTexture[i] == null ? "" : m_editAtlasSlot.SubTilesets[0].SourceTexture[i].name, m_editAtlasSlot.SubTilesets[0].SourceTexture[i], typeof(Texture2D), false) as Texture2D;
                    }
                }
                else
                { // if it is an object tileset, we have to modify this and the other 3 as object tilesets came in groups of 4
                    for (int i = 0; i < m_editAtlasSlot.SubTilesets.Count; ++i)
                    {
                        EditorGUILayout.LabelField(_GetSrcTextureName(i, m_editAtlasSlot.SubTilesets[i].HasAutotiles));
                        m_editAtlasSlot.SubTilesets[i].SourceTexture[0] = EditorGUILayout.ObjectField(m_editAtlasSlot.SubTilesets[i].SourceTexture[0] == null ? "" : m_editAtlasSlot.SubTilesets[i].SourceTexture[0].name, m_editAtlasSlot.SubTilesets[i].SourceTexture[0], typeof(Texture2D), false) as Texture2D;
                    }
                }
                EditorGUILayout.EndVertical();
            }

            GUILayout.EndScrollView();
        }
コード例 #8
0
ファイル: cEntity.cs プロジェクト: whztt07/HPL1Engine
		public virtual void Draw(Graphics aGfx,int alWorldX,int alWorldY ,eEditMode mMode, bool abSelected)
		{

		}
コード例 #9
0
        public bool ShowAsWindow(eWindowShowStyle windowStyle = eWindowShowStyle.Dialog, bool startupLocationWithOffset = false, eEditMode e = eEditMode.Design, Window parentWindow = null)
        {
            mApplicationAPIModel.StartDirtyTracking();
            //changed the style to be free - since many other windows get stuck and doesn't show
            // Need to find a solution if 2 windows show as Dialog...
            string title = "";

            this.Width  = 1100;
            this.Height = 800;

            editMode = e;
            ObservableList <Button> winButtons = new ObservableList <Button>();

            switch (editMode)
            {
            case eEditMode.Design:
                Button okBtn2 = new Button();
                okBtn2.Content = "Ok";
                okBtn2.Click  += new RoutedEventHandler(okBtn_Click);
                Button undoBtn2 = new Button();
                undoBtn2.Content = "Undo & Close";
                undoBtn2.Click  += new RoutedEventHandler(undoBtn_Click);
                winButtons.Add(okBtn2);
                winButtons.Add(undoBtn2);
                break;

            case eEditMode.View:
                title = "View " + mApplicationAPIModel.Name + " API Model";
                Button okBtnView = new Button();
                okBtnView.Content = "Ok";
                okBtnView.Click  += new RoutedEventHandler(okBtn_Click);
                winButtons.Add(okBtnView);
                break;

            case eEditMode.FindAndReplace:
                title = "Edit " + mApplicationAPIModel.Name + " API Model";
                mApplicationAPIModel.SaveBackup();
                Button saveBtnAnalyzer = new Button();
                saveBtnAnalyzer.Content = "Save";
                saveBtnAnalyzer.Click  += new RoutedEventHandler(saveBtn_Click);
                Button undoBtnAnalyzer = new Button();
                undoBtnAnalyzer.Content = "Undo & Close";
                undoBtnAnalyzer.Click  += new RoutedEventHandler(undoBtn_Click);
                winButtons.Add(undoBtnAnalyzer);
                winButtons.Add(saveBtnAnalyzer);
                break;

            case eEditMode.Edit:
                title = mApplicationAPIModel.Name + " Edit Page";
                mApplicationAPIModel.SaveBackup();

                Button saveBtn = new Button()
                {
                    Content = "Save"
                };
                saveBtn.Click += saveBtn_Click;

                Button undoChangesBtn = new Button()
                {
                    Content = "Undo & Close"
                };
                undoChangesBtn.Click += UndoChangesBtn_Click;

                winButtons.Add(saveBtn);
                winButtons.Add(undoChangesBtn);

                break;
            }
            if (parentWindow == null)
            {
                parentWindow = (Window)App.MainWindow;
            }

            GingerCore.General.LoadGenericWindow(ref _pageGenericWin, parentWindow, windowStyle, title, this, winButtons, false, string.Empty, CloseWinClicked, startupLocationWithOffset: startupLocationWithOffset);
            return(saveWasDone);
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: whztt07/HPL1Engine
		private void objModeParticlesButton_Click(object sender, System.EventArgs e)
		{
			if(mEditMode != eEditMode.Particles)
			{
				HideAllActiveForms();
				mlstActiveForms.Clear();
	
				mParticlesForm.Show();
				mlstActiveForms.Add(mParticlesForm);
				mLayersForm.Show();
				mlstActiveForms.Add(mLayersForm);
				
				
				mEditMode = eEditMode.Particles;
				mlstCurrentEntityList = mParticlesForm.mlstParticles;
				mlCurrentEntity=-1;
				
				mlstCopiedEntities.Clear();
				objMapPanel.Refresh();
			}
		}
コード例 #11
0
ファイル: Form1.cs プロジェクト: whztt07/HPL1Engine
		private void objModeSoundsSourceButon_Click(object sender, System.EventArgs e)
		{
			if(mEditMode != eEditMode.SoundSource)
			{
				HideAllActiveForms();
				mlstActiveForms.Clear();
	
				mSoundForm.Show();
				mlstActiveForms.Add(mSoundForm);
				
				mEditMode = eEditMode.SoundSource;
				mlstCurrentEntityList = mSoundForm.mlstSounds;
				mlCurrentEntity=-1;
				
				mlstCopiedEntities.Clear();
				objMapPanel.Refresh();
			}
		}
コード例 #12
0
        public VariableEditPage(VariableBase v, Context context, bool setGeneralConfigsAsReadOnly = false, eEditMode mode = eEditMode.Default, RepositoryItemBase parent = null)
        {
            InitializeComponent();

            this.Title = "Edit " + GingerDicser.GetTermResValue(eTermResKey.Variable);
            mVariable  = v;
            mVariable.SaveBackup();
            editMode = mode;
            mParent  = parent;
            mContext = context;
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(txtVarName, TextBox.TextProperty, mVariable, nameof(VariableBase.Name));
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(txtVarDescritpion, TextBox.TextProperty, mVariable, nameof(VariableBase.Description));
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(txtFormula, TextBox.TextProperty, mVariable, nameof(VariableBase.Formula), BindingMode.OneWay);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(txtCurrentValue, TextBox.TextProperty, mVariable, nameof(VariableBase.Value), BindingMode.OneWay);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(cbSetAsInputValue, CheckBox.IsCheckedProperty, mVariable, nameof(VariableBase.SetAsInputValue));
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(cbSetAsOutputValue, CheckBox.IsCheckedProperty, mVariable, nameof(VariableBase.SetAsOutputValue));

            if (mode == eEditMode.Global)
            {
                cbSetAsInputValue.Visibility    = Visibility.Hidden;
                cbSetAsOutputValue.Visibility   = Visibility.Hidden;
                SharedRepoInstanceUC.Visibility = Visibility.Collapsed;
                SharedRepoInstanceUC_Col.Width  = new GridLength(0);
            }
            else
            {
                if (mode == eEditMode.SharedRepository)
                {
                    SharedRepoInstanceUC.Visibility = Visibility.Collapsed;
                    SharedRepoInstanceUC_Col.Width  = new GridLength(0);
                }
                cbSetAsInputValue.Visibility  = Visibility.Visible;
                cbSetAsOutputValue.Visibility = Visibility.Visible;
                if (mContext != null && mContext.BusinessFlow != null)
                {
                    SharedRepoInstanceUC.Init(mVariable, mContext.BusinessFlow);
                }
            }

            if (setGeneralConfigsAsReadOnly)
            {
                txtVarName.IsEnabled              = false;
                txtVarDescritpion.IsEnabled       = false;
                TagsViewer.IsEnabled              = false;
                SharedRepoInstanceUC.IsEnabled    = false;
                cbSetAsInputValue.IsEnabled       = false;
                cbSetAsOutputValue.IsEnabled      = false;
                linkedvariableCombo.IsEnabled     = false;
                publishValueToLinkedBtn.IsEnabled = false;
            }
            if (editMode == eEditMode.View)
            {
                frmVarTypeInfo.IsEnabled = false;
            }
            else
            {
                frmVarTypeInfo.IsEnabled = true;
            }

            mVariable.PropertyChanged += mVariable_PropertyChanged;
            LoadVarPage();

            SetLinkedVarCombo();

            if (mVariable.Tags == null)
            {
                mVariable.Tags = new ObservableList <Guid>();
            }
            TagsViewer.Init(mVariable.Tags);
        }
コード例 #13
0
 public FrmSetSampler_Oper(CmcsSetSampler pId, eEditMode editMode)
 {
     InitializeComponent();
     noSampler     = pId;
     this.EditMode = editMode;
 }
コード例 #14
0
        public ActivitiesGroupPage(ActivitiesGroup activitiesGroup, BusinessFlow parentBusinessFlow = null, eEditMode mode = eEditMode.ExecutionFlow)
        {
            InitializeComponent();
            mEditMode        = mode;
            mActivitiesGroup = activitiesGroup;
            mActivitiesGroup.SaveBackup();
            mBusinessFlow = parentBusinessFlow;

            xShowIDUC.Init(mActivitiesGroup);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(txtGroupName, TextBox.TextProperty, mActivitiesGroup, nameof(ActivitiesGroup.Name));
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(txtGroupDescription, TextBox.TextProperty, mActivitiesGroup, nameof(ActivitiesGroup.Description));
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(txtAutoPrecentage, TextBox.TextProperty, mActivitiesGroup, nameof(ActivitiesGroup.AutomationPrecentage), BindingMode.OneWay);
            GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(xPublishcheckbox, CheckBox.IsCheckedProperty, mActivitiesGroup, nameof(RepositoryItemBase.Publish));

            SetGroupedActivitiesGridView();
            grdGroupedActivities.DataSourceList = mActivitiesGroup.ActivitiesIdentifiers;
            grdGroupedActivities.btnRefresh.AddHandler(Button.ClickEvent, new RoutedEventHandler(RefreshGroupedActivities));
            AttachActivitiesGroupAndRepositoryActivities();
            RefreshGroupedActivities();

            TagsViewer.Init(mActivitiesGroup.Tags);

            if (mEditMode == eEditMode.ExecutionFlow)
            {
                SharedRepoInstanceUC.Init(mActivitiesGroup, mBusinessFlow);
            }
            else
            {
                SharedRepoInstanceUC.Visibility = Visibility.Collapsed;
                SharedRepoInstanceUC_Col.Width  = new GridLength(0);
            }
        }
コード例 #15
0
 public virtual void Draw(Graphics aGfx, int alWorldX, int alWorldY, eEditMode mMode, bool abSelected)
 {
 }
コード例 #16
0
        void OnGUI_TilesetAtlas(bool isFirstUpdate)
        {
            GUILayout.Label("Tileset Atlas Configuration", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUI.backgroundColor = m_atlasEditMode == eAtlasEditMode.AddAutoTileset? Color.gray : Color.white;
            if (GUILayout.Button("Add AutoTileset", GUILayout.Height(25))) m_atlasEditMode = eAtlasEditMode.AddAutoTileset;
            GUI.backgroundColor = m_atlasEditMode == eAtlasEditMode.AddNormalTileset ? Color.gray : Color.white;
            if (GUILayout.Button("Add NormalTileset", GUILayout.Height(25))) m_atlasEditMode = eAtlasEditMode.AddNormalTileset;
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUI.backgroundColor = m_atlasEditMode == eAtlasEditMode.EditTileset ? Color.gray : Color.white;
            if (GUILayout.Button("Edit Tileset", GUILayout.Height(25))) m_atlasEditMode = eAtlasEditMode.EditTileset;
            GUI.backgroundColor = m_atlasEditMode == eAtlasEditMode.RemoveTileset ? Color.gray : Color.white;
            if (GUILayout.Button("Remove Tileset", GUILayout.Height(25))) m_atlasEditMode = eAtlasEditMode.RemoveTileset;
            GUI.backgroundColor = Color.white;
            GUILayout.EndHorizontal();

            int cols = m_autoTileset.AtlasTexture.width / m_autoTileset.TilesetSlotSize;
            //int rows = m_autoTileset.AtlasTexture.height / k_TilesetSlotSize;

            Rect rAtlas = new Rect(0, 0, m_autoTileset.AtlasTexture.width, m_autoTileset.AtlasTexture.height);

            if (rAtlas.width - position.width > rAtlas.height - (position.height - 120f))
            {
                rAtlas.width = Mathf.Min(position.width, rAtlas.width);
                rAtlas.height *= rAtlas.width / m_autoTileset.AtlasTexture.width;
            }
            else
            {
                rAtlas.height = Mathf.Min((position.height - 120f), rAtlas.height);
                rAtlas.width *= rAtlas.height / m_autoTileset.AtlasTexture.height;
            }

            GUILayout.Box(m_autoTileset.AtlasTexture, GUILayout.Width(rAtlas.width), GUILayout.Height(rAtlas.height));

            Rect rGuiAtlas = GUILayoutUtility.GetLastRect();
            Vector2 vBtnOff = new Vector2(0.2f * rGuiAtlas.width / cols, 0.40f * rGuiAtlas.width / cols);
            Rect rButton = new Rect(0, 0, rGuiAtlas.width / cols -  2f * vBtnOff.x, rGuiAtlas.width / cols - 2f * vBtnOff.y);
            float scale = rAtlas.width / m_autoTileset.AtlasTexture.width;
            GUIStyle btnStyle = new GUIStyle("button");
            btnStyle.richText = true;
            btnStyle.fontSize = (int)(50*scale);
            btnStyle.fontStyle = FontStyle.Bold;

            for (int i = 0; i < m_autoTileset.AtlasSlots.Count; ++i )
            {
                AtlasSlot atlasSlot = m_autoTileset.AtlasSlots[i];
                Rect rSlot = m_autoTileset.CalculateAtlasSlotRectByIdx(i);
                rButton.position = vBtnOff + rGuiAtlas.position + rSlot.position * scale;
                rButton.y = rGuiAtlas.y + rGuiAtlas.height - (rButton.y - rGuiAtlas.y) - rButton.height;

                if (atlasSlot.SubTilesets.Count == 0)
                {
                    GUI.color = new Color(0f, 0.7f, 1f, 0.8f);
                    Rect rSlotBox = rSlot;
                    rSlotBox.position *= scale;
                    rSlotBox.position += rGuiAtlas.position;
                    rSlotBox.width *= scale;
                    rSlotBox.height *= scale;
                    rSlotBox.y = rGuiAtlas.y + rGuiAtlas.height - (rSlotBox.y - rGuiAtlas.y) - rSlotBox.height;
                    GUI.Box(rSlotBox, "\n\nSlot " + (i + 1));
                }

                GUI.color = new Color(0f, 0.7f, 1f, 0.8f);

                //+++ Show name list
                if (m_atlasEditMode == eAtlasEditMode.None)
                {
                    if (atlasSlot.SubTilesets.Count == 1)
                    {
                        List<string> availableNames = m_autoTileset.CreateAvailableNameList();
                        availableNames.Insert(0, atlasSlot.SubTilesets[0].Name);
                        Rect rPopup = new Rect(rButton.x, rButton.y, 50, 20); rPopup.position -= vBtnOff;
                        int nameIdx = EditorGUI.Popup(rPopup, 0, availableNames.ToArray(), new GUIStyle("popup"));
                        atlasSlot.SubTilesets[0].Name = availableNames[nameIdx];
                    }
                    else
                    {
                        for (int j = 0; j < atlasSlot.SubTilesets.Count; ++j)
                        {
                            List<string> availableNames = m_autoTileset.CreateAvailableNameList();
                            availableNames.Insert(0, atlasSlot.SubTilesets[j].Name);
                            Rect rPopup = new Rect(rButton.x, rButton.y, 50, 20); rPopup.position -= vBtnOff;
                            if (j == 0)
                                rPopup.y += rSlot.height * scale / 2;
                            else if (j == 2)
                            {
                                rPopup.y += rSlot.height * scale / 2;
                                rPopup.x += rSlot.width * scale / 2;
                            }
                            else if (j == 3)
                            {
                                rPopup.x += rSlot.width * scale / 2;
                            }
                            int nameIdx = EditorGUI.Popup(rPopup, 0, availableNames.ToArray(), new GUIStyle("popup"));
                            atlasSlot.SubTilesets[j].Name = availableNames[nameIdx];
                        }
                    }
                }
                //---

                GUI.color = new Color(.5f, .5f, 0.5f, 0.7f);

                if (m_atlasEditMode == eAtlasEditMode.EditTileset && atlasSlot.SubTilesets.Count >= 1)
                {
                    if (GUI.Button(rButton, "<color=white>" + (atlasSlot.SubTilesets.Count > 1 ? "[+]" : "[A]") + "Edit</color>", btnStyle))
                    {
                        m_editAtlasSlot = atlasSlot;
                        m_editMode = eEditMode.ChangeTileset;
                        m_clearSlotOnCancel = false;
                        m_atlasEditMode = eAtlasEditMode.None;
                    }
                }
                else if (m_atlasEditMode == eAtlasEditMode.RemoveTileset && atlasSlot.SubTilesets.Count >= 1)
                {
                    if (GUI.Button(rButton, "<color=white>" + (atlasSlot.SubTilesets.Count > 1 ? "[+]" : "[A]") + "Remove</color>", btnStyle))
                    {
                        foreach( SubTilesetConf conf in atlasSlot.SubTilesets )
                        {
                            UtilsAutoTileMap.ClearAtlasArea(m_autoTileset.AtlasTexture, (int)conf.AtlasRec.x, (int)conf.AtlasRec.y, (int)conf.AtlasRec.width, (int)conf.AtlasRec.height);
                        }
                        atlasSlot.SubTilesets.Clear();
                        m_autoTileset.BuildSubTilesetsList();
                        EditorUtility.SetDirty(m_autoTileset);
                        if (m_autoTileset.SubTilesets.Count == 0)
                            m_atlasEditMode = eAtlasEditMode.None;
                    }
                }
                else if (m_atlasEditMode == eAtlasEditMode.AddAutoTileset && atlasSlot.SubTilesets.Count == 0)
                {
                    if (GUI.Button(rButton, "<color=white>Add AutoTileset</color>", btnStyle))
                    {
                        List<string> availableNames = m_autoTileset.CreateAvailableNameList();
                        atlasSlot.SubTilesets.Add(new SubTilesetConf() { Name = availableNames.Count > 0 ? availableNames[0] : "-", AtlasRec = rSlot, HasAutotiles = true });
                        m_autoTileset.BuildSubTilesetsList();
                        m_editAtlasSlot = atlasSlot;
                        m_editMode = eEditMode.ChangeTileset;
                        m_clearSlotOnCancel = true;
                        EditorUtility.SetDirty(m_autoTileset);
                    }
                }
                else if (m_atlasEditMode == eAtlasEditMode.AddNormalTileset && atlasSlot.SubTilesets.Count == 0)
                {
                    if (GUI.Button(rButton, "<color=white>Add Normal Tileset</color>", btnStyle))
                    {
                        List<string> availableNames = m_autoTileset.CreateAvailableNameList();
                        Rect rect = new Rect(rSlot.x, rSlot.y, rSlot.width / 2, rSlot.height / 2);
                        atlasSlot.SubTilesets.Add(new SubTilesetConf() { Name = availableNames.Count > 0 ? availableNames[0] : "-", AtlasRec = rect, HasAutotiles = false });
                        rect.y = rSlot.y + rect.height;
                        atlasSlot.SubTilesets.Add(new SubTilesetConf() { Name = availableNames.Count > 1 ? availableNames[1] : "-", AtlasRec = rect, HasAutotiles = false });
                        rect.x = rSlot.x + rect.width;
                        rect.y = rSlot.y;
                        atlasSlot.SubTilesets.Add(new SubTilesetConf() { Name = availableNames.Count > 2 ? availableNames[2] : "-", AtlasRec = rect, HasAutotiles = false });
                        rect.y = rSlot.y + rect.height;
                        atlasSlot.SubTilesets.Add(new SubTilesetConf() { Name = availableNames.Count > 3 ? availableNames[3] : "-", AtlasRec = rect, HasAutotiles = false });
                        m_autoTileset.BuildSubTilesetsList();
                        m_editAtlasSlot = atlasSlot;
                        m_editMode = eEditMode.ChangeTileset;
                        m_clearSlotOnCancel = true;
                        EditorUtility.SetDirty(m_autoTileset);
                    }
                }
            }
            GUI.color = Color.white;
            if ( m_atlasEditMode != eAtlasEditMode.None && GUILayout.Button("Cancel Action", GUILayout.Height(25))) m_atlasEditMode = eAtlasEditMode.None;
        }
コード例 #17
0
ファイル: Form1.cs プロジェクト: whztt07/HPL1Engine
		private void objModeAreaMode_Click(object sender, System.EventArgs e)
		{
			if(mEditMode != eEditMode.Area)
			{
				HideAllActiveForms();
				mlstActiveForms.Clear();
	
				mAreasForm.Show();
				mlstActiveForms.Add(mAreasForm);
								
				mEditMode = eEditMode.Area;
				mlstCurrentEntityList = mAreasForm.mlstAreas;
				mlCurrentEntity=-1;
				
				mlstCopiedEntities.Clear();
				objMapPanel.Refresh();
			}
		}
コード例 #18
0
ファイル: APIModelPage.xaml.cs プロジェクト: ramizilb/Ginger
        public void ShowAsWindow(eWindowShowStyle windowStyle = eWindowShowStyle.Free, bool startupLocationWithOffset = false, eEditMode e = eEditMode.Design)
        {
            //changed the style to be free - since many other windows get stuck and doesn't show
            // Need to find a solution if 2 windows show as Dialog...
            string title = "Edit " + mApplicationAPIModel.Description + " API Model";

            this.Width  = 1100;
            this.Height = 800;

            editMode = e;
            ObservableList <Button> winButtons = new ObservableList <Button>();

            switch (editMode)
            {
            case eEditMode.Design:
                Button okBtn2 = new Button();
                okBtn2.Content = "Ok";
                okBtn2.Click  += new RoutedEventHandler(okBtn_Click);
                Button undoBtn2 = new Button();
                undoBtn2.Content = "Undo & Close";
                undoBtn2.Click  += new RoutedEventHandler(undoBtn_Click);
                winButtons.Add(okBtn2);
                winButtons.Add(undoBtn2);
                break;

            case eEditMode.View:
                title = "View " + mApplicationAPIModel.Description + " API Model";
                Button okBtnView = new Button();
                okBtnView.Content = "Ok";
                okBtnView.Click  += new RoutedEventHandler(okBtn_Click);
                winButtons.Add(okBtnView);
                break;

            case eEditMode.FindAndReplace:
                title = "Edit " + mApplicationAPIModel.Description + " API Model";
                mApplicationAPIModel.SaveBackup();
                Button saveBtnAnalyzer = new Button();
                saveBtnAnalyzer.Content = "Save";
                saveBtnAnalyzer.Click  += new RoutedEventHandler(saveBtn_Click);
                Button undoBtnAnalyzer = new Button();
                undoBtnAnalyzer.Content = "Undo & Close";
                undoBtnAnalyzer.Click  += new RoutedEventHandler(undoBtn_Click);
                winButtons.Add(undoBtnAnalyzer);
                winButtons.Add(saveBtnAnalyzer);
                break;
            }
            GingerCore.General.LoadGenericWindow(ref _pageGenericWin, App.MainWindow, windowStyle, title, this, winButtons, false, string.Empty, CloseWinClicked, startupLocationWithOffset: startupLocationWithOffset);
        }