Changeset 2778
- Timestamp:
- 2012-06-04 16:03:38 (9 years ago)
- Location:
- 2012/23/RamiP/YAG2DSSBase/YAG2DSS/YAG2DSS
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/23/RamiP/YAG2DSSBase/YAG2DSS/YAG2DSS/ALTKHandler.cs
r2768 r2778 27 27 public static Cursor Cursor; 28 28 public static StaticAnimHandler StaticAnimHandler; 29 public static GUI.Dialogs.ExitWindow ExitWindow; 29 30 30 31 /// <summary> … … 48 49 Cursor.Initialize(); 49 50 Game.Components.Add(Cursor); 51 52 ExitWindow = new GUI.Dialogs.ExitWindow(Game); 53 ExitWindow.Initialize(); 54 ExitWindow.Visible = false; 55 ExitWindow.Enabled = false; 56 Game.Components.Add(ExitWindow); 50 57 } 51 58 -
2012/23/RamiP/YAG2DSSBase/YAG2DSS/YAG2DSS/GUI/AUIButton.cs
r2768 r2778 106 106 { 107 107 TextXAdd = Convert.ToInt32((Width - textSize.X) / 2); 108 //TextXAdd = Convert.ToInt32((textSize.X - Width) / -2); 108 109 } 109 110 else if (textSize.X > Width) … … 201 202 if (mpX > this.PositionX + baseX && 202 203 mpX < this.PositionX + baseX + this.Width && 203 mpY > this.PositionY + baseY &&204 mpY < this.PositionY + baseY + this.Height &&204 mpY > this.PositionY + baseY + this.Height / 2 && 205 mpY < this.PositionY + baseY + this.Height * 1.5 && 205 206 Locked == false) 206 207 { … … 344 345 if (IdleTexture != null) 345 346 { 347 int xPos = Convert.ToInt32(PositionX + baseX) - 10; 348 int yPos = Convert.ToInt32(PositionY + baseY); 349 350 Console.WriteLine("xPos: " + xPos + "; yPos: " + yPos); 351 346 352 if (HoverTexture == null) 347 353 { … … 352 358 if (CursoronButton == true) 353 359 { 354 spriteBatch.Draw(IdleTexture, new Rectangle( Convert.ToInt32(PositionX + baseX), Convert.ToInt32(PositionY + baseY), Width, Height), new Color(new Vector4(128, 128, 128, idleTextureAlpha)));355 spriteBatch.Draw(HoverTexture, new Rectangle( Convert.ToInt32(PositionX + baseX), Convert.ToInt32(PositionY + baseY), Width, Height), new Color(new Vector4(128, 128, 128, hoverTextureAlpha)));360 spriteBatch.Draw(IdleTexture, new Rectangle(xPos, yPos, Width, Height), new Color(new Vector4(128, 128, 128, idleTextureAlpha))); 361 spriteBatch.Draw(HoverTexture, new Rectangle(xPos, yPos, Width, Height), new Color(new Vector4(128, 128, 128, hoverTextureAlpha))); 356 362 } 357 363 else 358 364 { 359 spriteBatch.Draw(HoverTexture, new Rectangle( Convert.ToInt32(PositionX + baseX), Convert.ToInt32(PositionY + baseY), Width, Height), new Color(new Vector4(128, 128, 128, hoverTextureAlpha)));360 spriteBatch.Draw(IdleTexture, new Rectangle( Convert.ToInt32(PositionX + baseX), Convert.ToInt32(PositionY + baseY), Width, Height), new Color(new Vector4(128, 128, 128, idleTextureAlpha)));365 spriteBatch.Draw(HoverTexture, new Rectangle(xPos, yPos, Width, Height), new Color(new Vector4(128, 128, 128, hoverTextureAlpha))); 366 spriteBatch.Draw(IdleTexture, new Rectangle(xPos, yPos, Width, Height), new Color(new Vector4(128, 128, 128, idleTextureAlpha))); 361 367 } 362 368 } -
2012/23/RamiP/YAG2DSSBase/YAG2DSS/YAG2DSS/GUI/Dialogs/ExitWindow.cs
r2768 r2778 48 48 base.Initialize(); 49 49 50 backgroundTexture = CreateBackgroundTexture(); 50 backgroundTexture = CreateTexture(sizePos.Width, sizePos.Height, 51 new Color(96, 96, 128, 128), 52 new Color(32, 32, 255, 255), 53 new Color(96, 96, 96, 255)); 51 54 52 55 spriteBatch = new SpriteBatch(GraphicsDevice); … … 59 62 BExit.ButtonText = "Poistu"; 60 63 BExit.PositionY = 100.0f; 61 BExit.PositionX = 200.0f;64 BExit.PositionX = 100.0f; 62 65 BExit.TextColor = Color.Blue; 63 66 BExit.TextColorPressed = Color.Teal; 64 67 BExit.Width = 200; 65 68 BExit.Height = 30; 69 BExit.IdleTexture = CreateTexture(200, 30, 70 new Color(0, 102, 255, 196), 71 new Color(102, 0, 153, 255), 72 new Color(0, 0, 255, 168)); 73 BExit.HoverTexture = CreateTexture(200, 30, 74 new Color(0, 255, 153, 196), 75 new Color(0, 0, 255, 255), 76 new Color(102, 0, 153, 196)); 77 BExit.Initialize(); 78 79 //BExit.IdleTexture.SaveAsPng(System.IO.File.Create(Environment.CurrentDirectory + "\\texture.png"), 200, 30); 80 //Environment.Exit(0); 66 81 } 67 82 … … 71 86 } 72 87 73 74 75 private Texture2D CreateBackgroundTexture() 76 { 77 //GraphicsDevice gd = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, new PresentationParameters()); 78 Texture2D Texture = new Texture2D(GraphicsDevice, sizePos.Width, sizePos.Height, false, SurfaceFormat.Color); 79 80 Color[] color = new Color[sizePos.Width * sizePos.Height]; 81 82 Color backColor = new Color(96, 128, 96, 128); 83 Color borderColor = new Color(32, 255, 32, 255); 84 Color outerBorderColor = new Color(96, 96, 96, 255); 85 86 //Stopwatch sw = new Stopwatch(); 87 88 //sw.Start(); 88 private Texture2D CreateTexture(int width, int height, Color MainColor, Color SecondaryColor, Color TertiaryColor) 89 { 90 Texture2D Texture = new Texture2D(GraphicsDevice, width, height, false, SurfaceFormat.Color); 91 92 Color[] color = new Color[width * height]; 93 89 94 // background color 90 95 // *** 91 96 92 97 for (int i = 0; i < color.Length; i++) 93 color[i] = backColor;98 color[i] = MainColor; 94 99 95 100 // main border … … 98 103 // top 99 104 for (int i = sizePos.Width; i < (sizePos.Width * 3); i++) 100 color[i] = borderColor;105 color[i] = SecondaryColor; 101 106 102 107 // bottom 103 108 for (int i = color.Length - (sizePos.Width * 3); i < color.Length - sizePos.Width; i++) 104 color[i] = borderColor;109 color[i] = SecondaryColor; 105 110 106 111 // right 107 112 for (int i = 1; i < color.Length - sizePos.Width - 2; i = i + sizePos.Width) 108 color[i] = borderColor;113 color[i] = SecondaryColor; 109 114 110 115 for (int i = 2; i < color.Length - sizePos.Width - 2; i = i + sizePos.Width) 111 color[i] = borderColor;116 color[i] = SecondaryColor; 112 117 113 118 // left 114 119 for (int i = sizePos.Width - 3; i < color.Length; i = i + sizePos.Width) 115 color[i] = borderColor;120 color[i] = SecondaryColor; 116 121 117 122 for (int i = sizePos.Width - 2; i < color.Length; i = i + sizePos.Width) 118 color[i] = borderColor;123 color[i] = SecondaryColor; 119 124 120 125 // outer border … … 123 128 // top 124 129 for (int i = 0; i < sizePos.Width; i++) 125 color[i] = outerBorderColor;130 color[i] = TertiaryColor; 126 131 127 132 // bottom 128 133 for (int i = color.Length - sizePos.Width; i < color.Length; i++) 129 color[i] = outerBorderColor;134 color[i] = TertiaryColor; 130 135 131 136 // right 132 137 for (int i = 0; i < color.Length - sizePos.Width; i = i + sizePos.Width) 133 color[i] = outerBorderColor;138 color[i] = TertiaryColor; 134 139 135 140 // left 136 141 for (int i = sizePos.Width - 1; i < color.Length; i = i + sizePos.Width) 137 color[i] = outerBorderColor; 138 139 //sw.Stop(); 140 //Console.WriteLine("ADialogWindow texture creation time (ms): " + sw.ElapsedMilliseconds); 142 color[i] = TertiaryColor; 141 143 142 144 Texture.SetData(color); … … 152 154 // TODO: Add your update code here 153 155 154 //YAG2DSS.Instance.MessageDisplay.Add("UPDATING");155 156 156 bool cursorOnChoice = false; 157 157 158 158 YAG2DSS.Instance.MessageDisplay.Clear(); 159 YAG2DSS.Instance.MessageDisplay.Add("Rectangle: " + sizePos.X + "; " + sizePos.Y + "; " + sizePos.Width + "; " + sizePos.Height); 160 YAG2DSS.Instance.MessageDisplay.Add(Convert.ToString(ALTK.Cursor.SecPosX + "; " + ALTK.Cursor.SecPosY)); 161 162 //if (Cursor.SecPosX > sizePos.X && Cursor.SecPosY > sizePos.Y) 163 //{ 164 // YAG2DSS.Instance.MessageDisplay.Clear(); 165 // YAG2DSS.Instance.MessageDisplay.Add("ajajjajajaj xDDD"); 166 //} 159 YAG2DSS.Instance.MessageDisplay.Add(Cursor.SecPosX + "; " + Cursor.SecPosY); 160 YAG2DSS.Instance.MessageDisplay.Add(Convert.ToString(BExit.PositionX + sizePos.X) + "; " + Convert.ToString(BExit.PositionY + sizePos.Y)); 167 161 168 162 if (Cursor.SecPosX > sizePos.X && Cursor.SecPosY > sizePos.Y && … … 170 164 { 171 165 Cursor.enableBasicInput = false; 172 173 //YAG2DSS.Instance.MessageDisplay.Clear();174 YAG2DSS.Instance.MessageDisplay.Add("Cursor is on window");175 //dialogMousePosX = ms.X - sizePos.X;176 //dialogMousePosY = ms.Y - sizePos.Y;177 166 178 167 prevMousePosX = mousePosX; … … 208 197 Cursor.enableBasicInput = true; 209 198 199 BExit.Update(gameTime, sizePos.X, sizePos.Y); 200 210 201 base.Update(gameTime); 211 202 } … … 218 209 219 210 spriteBatch.End(); 211 212 BExit.Draw(gameTime, sizePos.X, sizePos.Y); 220 213 221 214 base.Draw(gameTime); -
2012/23/RamiP/YAG2DSSBase/YAG2DSS/YAG2DSS/YAG2DSS.cs
r2768 r2778 20 20 // TODO: Kirjoita ohjelmakoodisi tähä 21 21 22 Kursori = new GameObject(32, 32); 23 Kursori.Image = Image.FromStream(File.OpenRead(ALTKConstants.TexturePath + "cursor.png")); 24 Kursori.IsVisible = false; 22 25 AnalogHandler handler = new AnalogHandler(HandleCursor); 23 Kursori = new GameObject(32, 32);24 26 Mouse.ListenMovement(0.1, handler, ""); 25 Kursori.Image = Image.FromStream(File.OpenRead(ALTKConstants.TexturePath + "cursor.png"));26 27 Add(Kursori); 27 28 … … 150 151 { 151 152 //this.StopAll(); 152 ExitWindow exitWindow = new ExitWindow(this); 153 exitWindow.Initialize(); 154 this.Components.Add(exitWindow); 153 if (!ALTKHandler.ExitWindow.Enabled) 154 { 155 ALTKHandler.ExitWindow.Enabled = true; 156 ALTKHandler.ExitWindow.Visible = true; 157 158 Kursori.IsVisible = true; 159 } 155 160 } 156 161 } -
2012/23/RamiP/YAG2DSSBase/YAG2DSS/YAG2DSS/YAG2DSS.csproj
r2768 r2778 6 6 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 7 7 <Platform Condition=" '$(Platform)' == '' ">x86</Platform> 8 <OutputType> WinExe</OutputType>8 <OutputType>Exe</OutputType> 9 9 <AppDesignerFolder>Properties</AppDesignerFolder> 10 10 <RootNamespace>YAG2DSS</RootNamespace> … … 60 60 <PlatformTarget>x86</PlatformTarget> 61 61 <XnaCompressContent>true</XnaCompressContent> 62 </PropertyGroup> 63 <PropertyGroup> 64 <StartupObject /> 62 65 </PropertyGroup> 63 66 <ItemGroup> … … 132 135 </ItemGroup> 133 136 <ItemGroup> 134 <Content Include="GUI\aMainFont.xml" />135 137 <Content Include="Game.ico" /> 136 138 <Content Include="GameThumbnail.png" />
Note: See TracChangeset
for help on using the changeset viewer.