private void DrawLedgePalette() { for (int i = 0; i < 16; i++) { if (map.Ledges[i] == null) { continue; } var y = (int)ledgePaletteLocation[i].Y; if (currentLedge == i) { Text.Color = Color.Lime; Text.DrawText(paletteOffsetX, y, "ledge " + i.ToString()); } else { Text.DrawClickText(paletteOffsetX, y, "ledge " + i.ToString(), mouseX, mouseY, mouseClick); } Text.Color = Color.White; Text.DrawText(708, y, "n" + map.Ledges[i].TotalNodes.ToString()); Text.DrawClickText(768, y, "f" + map.Ledges[i].Flags.ToString(), mouseX, mouseY, mouseClick); } }
private void DrawLedgePalette() { for (var i = 0; i < 16; i++) { if (_map.Ledges[i] == null) { continue; } var y = 50 + i * 20; if (_curLedge == i) { _text.Color = Color.Lime; _text.DrawText(520, y, "ledge " + i); } else { if (_text.DrawClickText(520, y, "ledge " + i, _mosX, _mosY, _mouseClick)) { _curLedge = i; } } _text.Color = Color.White; _text.DrawText(620, y, "n" + _map.Ledges[i].TotalNodes); if (_text.DrawClickText(680, y, "f" + _map.Ledges[i].Flags, _mosX, _mosY, _mouseClick)) { _map.Ledges[i].Flags = (_map.Ledges[i].Flags + 1) % 2; } } }
private void OnMouseLeftButtonClick(MouseState mouseState) { mouseClick = true; if (Text.DrawClickText(5, 5, "Layer: " + layerName, mouseState.X, mouseState.Y, mouseClick)) { currentLayer = (currentLayer + 1) % 3; } if (Text.DrawClickText(5, 25, "draw: " + layerName, mouseX, mouseY, mouseClick)) { drawingMode = (DrawingMode)((int)(drawingMode + 1) % 3); } if (drawingMode == DrawingMode.Ledges) { for (int i = 0; i < 16; i++) { var y = (int)ledgePaletteLocation[i].Y; if (Text.DrawClickText(paletteOffsetX, y, "ledge " + i.ToString(), mouseX, mouseY, mouseClick)) { currentLedge = i; } if (Text.DrawClickText(768, y, "f" + map.Ledges[i].Flags.ToString(), mouseX, mouseY, mouseClick)) { map.Ledges[i].Flags = (map.Ledges[i].Flags + 1) % 2; } } } if (Text.DrawClickText(5, 45, map.Path, mouseX, mouseY, mouseClick)) { editingMode = EditingMode.Path; } if (DrawButton(5, 65, 3, mouseX, mouseY, mouseClick)) { map.Save(); } if (DrawButton(40, 65, 4, mouseX, mouseY, mouseClick)) { map.Load(); } Console.WriteLine("X = {0}, Y = {1}", mouseState.X, mouseState.Y); }
private void DrawText() { switch (currentLayer) { case 0: layerName = "0:background"; break; case 1: layerName = "1:middle"; break; case 2: layerName = "2:foreground"; break; } Text.DrawClickText(5, 5, "Layer: " + layerName, mouseX, mouseY, false); switch (drawingMode) { case DrawingMode.SegmentSelection: layerName = "segement"; break; case DrawingMode.CollisionMap: layerName = "collison"; break; case DrawingMode.Ledges: layerName = "ledge"; break; } Text.DrawClickText(5, 25, "draw: " + layerName, mouseX, mouseY, false); Text.Color = Color.White; if (editingMode == EditingMode.Path) { Text.DrawText(5, 45, map.Path + "*"); } else { Text.DrawClickText(5, 45, map.Path, mouseX, mouseY, false); } }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { Rectangle sRect = new Rectangle(); Rectangle dRect = new Rectangle(); graphics.GraphicsDevice.Clear(Color.CornflowerBlue); map.Draw(sprite, mapsTex, scroll); //if (drawType == DRAW_COL) DrawGrid(); DrawLedges(); sprite.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); Color oColor = new Color(new Vector4(1.0f, 1.0f, 1.0f, 0.3f)); sprite.Draw(nullTex, new Rectangle(100, 50, 400, 1), oColor); sprite.Draw(nullTex, new Rectangle(100, 50, 1, 500), oColor); sprite.Draw(nullTex, new Rectangle(500, 50, 1, 500), oColor); sprite.Draw(nullTex, new Rectangle(100, 550, 400, 1), oColor); sprite.Draw(nullTex, new Rectangle(100, 300, 400, 1), oColor); sprite.End(); String layerName = "map"; switch (curLayer) { case 0: layerName = "back"; break; case 1: layerName = "mid"; break; case 2: layerName = "fore"; break; } if (text.DrawClickText(5, 5, "layer: " + layerName, mosX, mosY, mouseClick)) { curLayer = (curLayer + 1) % 3; } switch (drawType) { case DRAW_SELECT: layerName = "select"; break; case DRAW_COL: layerName = "col"; break; case DRAW_LEDGE: layerName = "ledge"; break; case DRAW_SCRIPT: layerName = "script"; break; } if (text.DrawClickText(5, 25, "draw: " + layerName, mosX, mosY, mouseClick)) { drawType = (drawType + 1) % 4; } if (drawType == DRAW_SCRIPT) { sprite.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); sprite.Draw(nullTex, new Rectangle(400, 20, 400, 565), new Color( new Vector4(0f, 0f, 0f, .62f))); sprite.End(); for (int i = scriptScroll; i < scriptScroll + 28; i++) { if (selScript == i) { text.SetColor(Color.White); text.DrawText(405, 25 + (i - scriptScroll) * 20, i.ToString() + ": " + map.script[i] + "*"); } else { if (text.DrawClickText(405, 25 + (i - scriptScroll) * 20, i.ToString() + ": " + map.script[i], mosX, mosY, mouseClick)) { selScript = i; editingText = EDITING_SCRIPT; } } if (map.script[i].Length > 0) { String[] split = map.script[i].Split(' '); int c = GetCommandColor(split[0]); if (c > COLOR_NONE) { switch (c) { case COLOR_GREEN: text.SetColor(Color.Lime); break; case COLOR_YELLOW: text.SetColor(Color.Yellow); break; } text.DrawText(405, 25 + (i - scriptScroll) * 20, i.ToString() + ": " + split[0]); } } text.SetColor(Color.White); text.DrawText(405, 25 + (i - scriptScroll) * 20, i.ToString() + ": "); } if (drawButton(770, 20, 1, mosX, mosY, mouseDown) && scriptScroll > 0) { scriptScroll--; } if (drawButton(770, 550, 2, mosX, mosY, mouseDown) && scriptScroll < map.script.Length - 28) { scriptScroll++; } } if (drawType == DRAW_LEDGE) { for (int i = 0; i < 16; i++) { int y = 50 + i * 20; if (curLedge == i) { text.SetColor(Color.Lime); text.DrawText(520, 50 + i * 20, "ledge " + i.ToString()); } else { if (text.DrawClickText(520, 50 + i * 20, "ledge " + i.ToString(), mosX, mosY, mouseClick)) { curLedge = i; } } text.SetColor(Color.White); text.DrawText(620, 50 + i * 20, "n" + map.GetLedgeTotalNodes(i).ToString()); if (text.DrawClickText(680, 50 + i * 20, "f" + map.GetLedgeFlags(i).ToString(), mosX, mosY, mouseClick)) { map.SetLedgeFlags(i, (map.GetLedgeFlags(i) + 1) % 2); } } } text.SetColor(Color.White); if (editingText == EDITING_PATH) { text.DrawText(5, 45, map.path + "*"); } else { if (text.DrawClickText(5, 45, map.path, mosX, mosY, mouseClick)) { editingText = EDITING_PATH; } } if (drawButton(5, 65, 3, mosX, mosY, mouseClick)) { map.Write(); map.Write(true); } if (drawButton(40, 65, 4, mosX, mosY, mouseClick)) { map.Read(); } for (int i = selScroll; i < selScroll + 20; i++) { if (map.GetSegIdx(curLayer, i) > -1) { SegmentDefinition segDef = map.GetSegDef(map.GetSegIdx(curLayer, i)); if (selIdx == i) { text.SetColor(Color.Lime); text.DrawText(5, 100 + (i - selScroll) * 16, segDef.GetName()); } else { if (text.DrawClickText( 5, 100 + (i - selScroll) * 16, segDef.GetName(), mosX, mosY, mouseClick)) { selIdx = i; } } } } if (drawButton(100, 100, 1, mosX, mosY, mouseDown)) { if (selScroll > 0) { selScroll--; } } if (drawButton(100, 500, 2, mosX, mosY, mouseDown)) { if (selScroll < 43) { selScroll++; } } if (drawButton(5, 500, 1, mosX, mosY, mouseDown)) { if (selIdx > 0) { map.SwapSegs(curLayer, selIdx, selIdx - 1); selIdx--; } } if (drawButton(25, 500, 2, mosX, mosY, mouseDown)) { if (selIdx < 63) { map.SwapSegs(curLayer, selIdx, selIdx + 1); selIdx++; } } if (drawType == DRAW_SELECT) { sprite.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); sprite.Draw(nullTex, new Rectangle(500, 20, 280, 550), new Color( new Vector4(0.0f, 0.0f, 0.0f, 0.4f))); sprite.End(); for (int i = segScroll; i < segScroll + 9; i++) { SegmentDefinition segDef = map.GetSegDef(i); if (segDef != null) { sprite.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); dRect.X = 500; dRect.Y = 50 + (i - segScroll) * 60; sRect = segDef.GetSrcRect(); if (sRect.Width > sRect.Height) { dRect.Width = 45; dRect.Height = (int)(((float)sRect.Height / (float)sRect.Width) * 45.0f); } else { dRect.Height = 45; dRect.Width = (int)(((float)sRect.Width / (float)sRect.Height) * 45.0f); } sprite.Draw(mapsTex[map.GetSegDef(i).GetSrcIdx()], dRect, sRect, Color.White); sprite.End(); text.SetSize(0.5f); text.SetColor(Color.White); text.DrawText(dRect.X + 50, dRect.Y, segDef.GetName()); if (mouseDown) { if (mosX > dRect.X && mosX < 700 && mosY > dRect.Y && mosY < dRect.Y + 45) { if (mouseDragSeg == -1) { int f = map.AddSeg(curLayer, i); if (f > -1) { float layerScalar = 0.5f; if (curLayer == 0) { layerScalar = 0.375f; } if (curLayer == 2) { layerScalar = 0.675f; } map.SetSegLoc(curLayer, f, new Vector2((float)(mosX - sRect.Width / 4 + scroll.X * layerScalar), (float)(mosY - sRect.Height / 4 + scroll.Y * layerScalar))); mouseDragSeg = f; pMosX = mosX; pMosY = mosY; } } } } } } if (drawButton(740, 20, 1, mosX, mosY, mouseDown)) { if (segScroll > 0) { segScroll--; } } if (drawButton(740, 550, 2, mosX, mosY, mouseDown)) { if (segScroll < 80) { segScroll++; } } } Vector2 v = new Vector2((float)mosX, (float)mosY) + scroll / 2.0f; v *= 2f; text.SetSize(.5f); text.SetColor(Color.White); text.DrawText(5, 580, ((int)v.X).ToString() + ", " + ((int)v.Y).ToString()); DrawCursor(); mouseClick = false; base.Draw(gameTime); }