public ColorPickerCtrl(int imageID, float scaleX, float scaleY) { InitializeComponent(); m_nScaleX = scaleX; m_nScaleY = scaleY; mD3d = ManagedDirect3D.Instance; mTM = ManagedTextureManager.Instance; m_nImageID = imageID; }
public Form1() { InitializeComponent(); version11ToolStripMenuItem.Text += m_strVersionNumber; this.KeyPreview = true; this.Text += " - " + m_strSaveFileName; //splitContainer1.Focus(); ////////////////////////////////////////////////////////////////////////// // set up the timer m_timer = new Timer(); m_timer.Enabled = true; m_timer.Interval = 2; m_timer.Start(); m_timer.Tick += new EventHandler(timer_Tick); ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // set up the texture mngr & d3d device m_mD3d = ManagedDirect3D.Instance; m_mD3d.InitManagedDirect3D(this.splitContainer1.Panel2, this.splitContainer1.Panel2.Width, this.splitContainer1.Panel2.Height, true, false); m_mTM = ManagedTextureManager.Instance; m_mTM.InitManagedTextureManager(m_mD3d.Device, m_mD3d.Sprite); dotID = m_mTM.LoadTexture("dot.png", 0); ////////////////////////////////////////////////////////////////////////// //Set up input boxes nudAdjustRectHeight.Enabled = false; nudAdjustRectWidth.Enabled = false; nudAdjustRectX.Enabled = false; nudAdjustRectY.Enabled = false; cbLayerMode.SelectedIndex = 0; cbLayer.SelectedIndex = 0; cbShowFlags.Checked = true; cbShowGrid.Checked = true; ////////////////////////////////////////////////////////////////////////// lbCurrentLayer.Text = m_strLayerLabel + "Layer 1"; splitContainer1.Panel2.AutoScrollMinSize = new Size((int)nudMapCellSize.Value * (int)nudMapNumCols.Value, ((int)nudMapCellSize.Value >> 1) * (int)nudMapNumRows.Value); }
private void btnOpenImage_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "All Files|*.*|Bitmap Files|*.bmp"; ofd.FileName = ".bmp"; if (DialogResult.OK == ofd.ShowDialog()) { string ext = Path.GetExtension(ofd.FileName); if (ext == ".bmp" || ext == ".jpg" || ext == ".png" || ext == ".tiff") { m_strFileName = ofd.FileName; mTM = ManagedTextureManager.Instance; mD3d = ManagedDirect3D.Instance; m_nImageID = mTM.LoadTexture(m_strFileName, Color.FromArgb (m_clrKey.R, m_clrKey.G, m_clrKey.B).ToArgb ()); decimal width, height; width = mTM.GetTextureWidth(m_nImageID); height = mTM.GetTextureHeight(m_nImageID); bool ok = true; if (width > nudImageWidth.Maximum) { ok = false; MessageBox.Show("Image width value too large, load a smaller image.", "Error", MessageBoxButtons.OK); } else if (width < nudCellWidth.Value) { ok = false; MessageBox.Show("Image width value too small, load a larger image.", "Error", MessageBoxButtons.OK); } if (height > nudImageHeight.Maximum) { ok = false; MessageBox.Show("Image height value too large, load a smaller image.", "Error", MessageBoxButtons.OK); } else if (height < nudCellHeight.Value) { ok = false; MessageBox.Show("Image height value too small, load a larger image.", "Error", MessageBoxButtons.OK); } if (ok) { nudImageWidth.Value = width; nudImageHeight.Value = height; toolStripStatusLabel1.Text = "Image : Loaded -- " + m_strFileName; scaleX = 494f / (float)(mTM.GetTextureWidth(m_nImageID)); scaleY = 424f / (float)(mTM.GetTextureHeight(m_nImageID)); thisScaleX = panel1.Width / (float)(mTM.GetTextureWidth(m_nImageID)); thisScaleY = panel1.Height / (float)(mTM.GetTextureHeight(m_nImageID)); btnKeyClr.Enabled = true; } } } }
public CTileset(int imageID, Color key, int width, int height, int cellWidth, int cellHeight, string filepath) { mD3d = ManagedDirect3D.Instance; mTM = ManagedTextureManager.Instance; m_nCurrLayer = 0; nTilesetImageID = imageID; m_nImageWidth = m_nTilesetWidth = width; m_nImageHeight = m_nTilesetHeight = height; m_strFilePath = filepath; m_nCellSize = cellWidth; NCellWidth = cellWidth; m_nCellHeight = cellHeight; m_nNumCols = m_nImageWidth / cellWidth; m_nNumRows = m_nImageHeight / cellHeight; m_nTotalNumTiles = m_nNumCols * m_nNumRows; m_gTilesetGrid = new CGrid(cellWidth, cellHeight, m_nNumCols, m_nNumRows, 0, 0, nOffsetX, nOffsetY, false, -1); m_gTilesetGrid.NImageHeight = m_nImageHeight; m_gTilesetGrid.NImageWidth = m_nImageWidth; m_strFilePath = filepath; if (key != null) clrKey = key; else clrKey = Color.White; if (cellHeight == cellWidth) SetupTileset(0, imageID); else SetupTilesetNotSquare(0, imageID); }
// CTORs public CTileset() { mD3d = ManagedDirect3D.Instance; mTM = ManagedTextureManager.Instance; }
public CGrid(int cellWidth, int cellHeight, int numVertical, int numHorizontal, int gridZoom, int zoomIncrement, int xOff, int yOff, bool bIsIso, int type) { // where to start drawing the grid m_nOffsetX = xOff; m_nOffsetY = yOff; // line color clrGridLines = Color.Black; // dimensions m_nCellWidth = cellWidth; m_nCellHeight = cellHeight; m_nNumRows = numVertical; m_nNumCols = numHorizontal; m_nTotalTiles = m_nNumCols * m_nNumRows; NNumVertLines = numVertical + 1; //always one more line than there are tiles NNumHorizontalLines = numHorizontal + 1; m_nZoomIncrement = zoomIncrement; NGridZoom = gridZoom; // line begin and end points ptGridLinesVertEnd = new Point[NNumVertLines]; ptGridLinesVert = new Point[NNumVertLines]; ptGridLinesHorizEnd = new Point[NNumHorizontalLines]; ptGridLinesHoriz = new Point[NNumHorizontalLines]; tilePoints = new Point[m_nTotalTiles]; m_bIsIsometric = bIsIso; if (m_bIsIsometric) { m_nType = type; switch (m_nType) { case (int)IsoType.ISO_DIAMOND: { m_nIsoCenterX = (m_nNumCols >> 1) * cellWidth + (cellWidth >> 1); } break; case (int)IsoType.ISO_SLIDE: break; case (int)IsoType.ISO_STAG: { // TODO::get these to center for staggered m_nIsoCenterX = cellWidth; } break; } } // the d3d device to draw lines mD3d = ManagedDirect3D.Instance; mTM = ManagedTextureManager.Instance; }
// isometric Map constructor public CMap(int isoWidth, int isoHeight, int numCols, int numRows, int zoomIncrement, bool bisometric, int type, int clientHeight, int clientWidth) { m_nCurrLayer = (int)LAYER.LAYER_ONE; m_nLayerMode = (int)LAYER_MODE.SHOW_L1; mTM = ManagedTextureManager.Instance; mD3d = ManagedDirect3D.Instance; m_nMapWidth = isoWidth * numCols; m_nMapHeight = isoHeight * numRows; // TODO:: how to do zoom with iso? /* nCellSize = cellSize;*/ m_nCellWidth = isoWidth; m_nCellHeight = isoHeight; m_nType = type; m_nNumCols = numCols; m_nNumRows = numRows; m_nZoom = 1.0f; nZoomIncrement = zoomIncrement; m_nTotalNumTiles = numCols * numRows; m_bIsIsometric = bisometric; m_gMapGrid = new CGrid(isoWidth, isoHeight, m_nNumRows, m_nNumCols, 0, nZoomIncrement, yOffset, yOffset, true, type); if (type == (int)IsoType.ISO_DIAMOND) m_gMapGrid.CenterOnY(clientHeight, m_nMapHeight); else if (type == (int)IsoType.ISO_STAG) { m_nMapHeight = (isoHeight >> 1) * numRows; if (m_nMapHeight < clientHeight-100) m_gMapGrid.CenterOnY(clientHeight-100, m_nMapHeight); else m_gMapGrid.SetMapY(m_nCellHeight); m_gMapGrid.CenterOnX(clientWidth, m_nMapWidth); } SetClearStrings(); NewMapTileArray(); }
public CMap(int cellSize, int numCols, int numRows, int zoomIncrement, bool bisometric) { m_nCurrLayer = (int)LAYER.LAYER_ONE; m_nLayerMode = (int)LAYER_MODE.SHOW_L1; mTM = ManagedTextureManager.Instance; mD3d = ManagedDirect3D.Instance; m_nMapWidth = cellSize * numCols; m_nMapHeight = cellSize * numRows; m_nCellSize = cellSize; m_nCellWidth = cellSize; m_nCellHeight = cellSize; m_nNumCols = numCols; m_nNumRows = numRows; m_nZoom = 1.0f; nZoomIncrement = zoomIncrement; m_nTotalNumTiles = numCols * numRows; m_bIsIsometric = bisometric; m_gMapGrid = new CGrid(m_nCellSize, m_nCellSize, m_nNumRows, m_nNumCols, 0, nZoomIncrement, 0, 0, false, -1); SetClearStrings(); NewMapTileArray(); }