private void UpdateAtlasList() { string filterString = this.textBoxSearch.Text.Trim(); bool nofilter = string.IsNullOrEmpty(filterString); this.listViewAtlas.BeginUpdate(); this.listViewAtlas.Items.Clear(); NTexAtlasItem item = new NTexAtlasItem(); bool next = m_resource.FirstItem(ref item); System.Windows.Rect itemRc = new System.Windows.Rect(); while (next) { Vector2 itemSize = item.uvEnd - item.uvStart; itemRc.X = item.uvStart.x * m_imgSize.Width; itemRc.Y = item.uvStart.y * m_imgSize.Height; itemRc.Width = itemSize.x * m_imgSize.Width; itemRc.Height = itemSize.y * m_imgSize.Height; if (nofilter || item.Name.IndexOf(filterString, StringComparison.OrdinalIgnoreCase) != -1) { ListViewItem listItem = new ListViewItem(); listItem.Text = string.Format("{0} [{1},{2}]", item.Name, itemRc.Width, itemRc.Height); listItem.Tag = item; this.listViewAtlas.Items.Add(listItem); } next = m_resource.NextItem(ref item); }// end of while() this.listViewAtlas.EndUpdate(); }
private void pictureBoxMain_MouseClick(object sender, MouseEventArgs e) { if (m_resource == null) { return; } System.Windows.Point clickPt = new System.Windows.Point(e.X, e.Y); System.Windows.Rect itemRc = new System.Windows.Rect(); NTexAtlasItem item = new NTexAtlasItem(); bool next = m_resource.FirstItem(ref item); while (next) { Vector2 itemSize = item.uvEnd - item.uvStart; itemRc.X = item.uvStart.x * m_imgSize.Width; itemRc.Y = item.uvStart.y * m_imgSize.Height; itemRc.Width = itemSize.x * m_imgSize.Width; itemRc.Height = itemSize.y * m_imgSize.Height; if (itemRc.Contains(clickPt)) { m_selectedItem = item; this.propertyGridItem.SelectedObject = m_selectedItem; this.pictureBoxMain.Invalidate(); return; } next = m_resource.NextItem(ref item); }// end of while() m_selectedItem = new NTexAtlasItem(); }
private void ReLoadTextures() { if (textureLoc != null && textureLoc.IsValid() && !string.IsNullOrEmpty(textureLoc.FileName) && !string.IsNullOrEmpty(textureLoc.PackageName)) { texture = NResourceManager.Instance.LoadResourceTexture2D( textureLoc, EResourceIOMode.Auto, EResourceIOPriority.Normal); } else { Texture = null; } if (alphaMapLoc != null && alphaMapLoc.IsValid() && !string.IsNullOrEmpty(alphaMapLoc.FileName) && !string.IsNullOrEmpty(alphaMapLoc.PackageName)) { alphaMap = NResourceManager.Instance.LoadTextureAtlas( alphaMapLoc, EResourceIOMode.Auto, EResourceIOPriority.Normal); if (alphaMap != null) { NTexAtlasItem item = alphaMap.GetItem(alphaMapAtlasName); alphaMapUVRect = new Rect(item.UVStart.x, item.UVStart.y, item.UVEnd.x, item.UVEnd.y); } } else { alphaMap = null; } }
public ResTextureAtlasViewer() { InitializeComponent(); m_finalClose = false; m_selectedItem = new NTexAtlasItem(); this.propertyGridItem.SelectedObject = m_selectedItem; }
private void listViewAtlas_SelectedIndexChanged(object sender, EventArgs e) { if (this.listViewAtlas.SelectedItems.Count != 1) { return; } ListViewItem item = this.listViewAtlas.SelectedItems[0]; if (item.Tag is NTexAtlasItem) { m_selectedItem = (NTexAtlasItem)item.Tag; this.propertyGridItem.SelectedObject = m_selectedItem; this.pictureBoxMain.Invalidate(); } }
virtual protected void OnAltasItemChanged(GUIEventArgs gUIEventArgs) { NResourceTextureAtlas texAtlas = TextureAtlas; if (texAtlas != null) { NTexAtlasItem item = texAtlas.GetItem(atlasItemName); TextureUVRect = new Rect(item.UVStart.x, item.UVStart.y, item.UVEnd.x, item.UVEnd.y); if (AltasRectChanged != null) { AltasRectChanged(this, new GUIEventArgs()); } } if (AltasItemChanged != null) { AltasItemChanged(this, gUIEventArgs); } }
public bool LoadFrame() { WindowCollection windowCollection = GameHelper.LoadUIForm(GUISystem.Instance.RootWindow, "content", "/ui/form/MiniMap.nui"); if (windowCollection != null) { miniMap = (Nexus.GUI.Widgets.UIShapedImageBox)GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UIShapedImageBox1", true); coordLabel = (Nexus.GUI.Widgets.UILabel)GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UILabel1", true); if (miniMap != null) { miniMap.BackgroundRenderComp.ImageLocation = new NResourceLoc("content", "/minimap/minimap.dds"); miniMapSize = miniMap.BackgroundRenderComp.Texture.GetOriginalSize(); Vector2 center = new Vector2(miniMapSize.x * 0.5f, miniMapSize.y * 0.5f); miniMap.BackgroundRenderComp.TextureRect = new Rect(center.x - minimapRange.x, center.y - minimapRange.y, center.x + minimapRange.x, center.y + minimapRange.y); Vector3 scale = GameEngine.EngineInstance.CurrentLevel.NavigationMapScale; sceneSize.x = GameEngine.EngineInstance.CurrentLevel.NavigationMapWidth * scale.x; sceneSize.y = GameEngine.EngineInstance.CurrentLevel.NavigationMapHeight * scale.z; minimapRatio.x = minimapRange.x * 2 / miniMap.Width.offest; minimapRatio.y = minimapRange.y * 2 / miniMap.Height.offest; Icons = NResourceManager.Instance.LoadTextureAtlas(new NResourceLoc("content", "/ui/texAtlas/content1.txa"), EResourceIOMode.Auto, EResourceIOPriority.Normal); if (Icons == null) { return(false); } { NTexAtlasItem item = Icons.GetItem("minimap_6"); playerIcon = new Rect(item.UVStart.x, item.UVStart.y, item.UVEnd.x, item.UVEnd.y); } { NTexAtlasItem item = Icons.GetItem("minimap-5"); northIcon = new Rect(item.UVStart.x, item.UVStart.y, item.UVEnd.x, item.UVEnd.y); } { NTexAtlasItem item = Icons.GetItem("minimap-5"); aroundRoleIcon = new Rect(item.UVStart.x, item.UVStart.y, item.UVEnd.x, item.UVEnd.y); } //------------------------------------------------------ miniMap.BackgroundRenderComp.OnRendering += this.OnDraw; Window win = GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UIButton2", true); if (win != null) { win.MouseClicked += this.ZoomIn; } win = GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UIButton3", true); if (win != null) { win.MouseClicked += this.ZoomOut; } win = GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UIButton4", true); if (win != null) { win.MouseClicked += this.OnMinsize; } win = GUISystem.Instance.RootWindow.FindChild("root/UIStaticImage1/UIButton5", true); if (win != null) { win.MouseClicked += this.OnShowWorldMap; } // 添加测试用角色 RoleAround a = new RoleAround(1, RoleStandpoint.RoleFriendly); roleAround.Add(a); RoleAround b = new RoleAround(2, RoleStandpoint.RoleNeutrally); roleAround.Add(b); RoleAround c = new RoleAround(3, RoleStandpoint.RoleHostile); roleAround.Add(c); a.Position = new Vector2(500, 400); b.Position = new Vector2(450, 500); c.Position = new Vector2(550, 450); } } return(windowCollection != null); }