// i = 49 ou 50 //Loohy public BoutonDeroulant(Rectangle rect_, int indexDico_) : base(rect_, new Rectangle(42,7,42,7)) { state = e_etatDeroulant.Ferme; tstate = e_pinceau.Plaine; tsize = e_toolSize.Standard; hauteur = 0; indexDico = indexDico_; }
public void updatePinceau(e_pinceau type_, e_toolSize taille_) { //brille(taille_); #region clic if (Mouse.GetState().LeftButton == ButtonState.Pressed) { int size; #region getsize switch (taille_) { case e_toolSize.XSmall: size = 1; break; case e_toolSize.Small: size = 2; break; case e_toolSize.Standard: size = 3; break; case e_toolSize.Medium: size = 4; break; case e_toolSize.Large: size = 5; break; case e_toolSize.XLarge: size = 6; break; default: size = 1; break; } #endregion #region Lissage if (type_ == e_pinceau.Lissage) { int moy = 0; int n = 1; moy += map[sourisI, sourisJ].altitude; for (int portee_ = 0; portee_ < size; portee_++) { for (int k = 0; k < portee_; k++) { if (sourisI + k >= 0 && sourisI + k < longueur && sourisJ + (portee_ - k) >= 0 && sourisJ + (portee_ - k) < largeur) { moy += map[sourisI + k, sourisJ + (portee_ - k)].altitude; n++; } if (sourisI - k >= 0 && sourisI - k < longueur && sourisJ - (portee_ - k) >= 0 && sourisJ - (portee_ - k) < largeur) { moy += map[sourisI - k, sourisJ - (portee_ - k)].altitude; n++; } if (sourisI + (portee_ - k) >= 0 && sourisI + (portee_ - k) < longueur && sourisJ - k >= 0 && sourisJ - k < largeur) { moy += map[sourisI + (portee_ - k), sourisJ - k].altitude; n++; } if (sourisI - (portee_ - k) >= 0 && sourisJ + k < largeur && sourisJ + k >= 0 && sourisJ + k < largeur) { moy += map[sourisJ - (portee_ - k), sourisJ + k].altitude; n++; } } } moy /= n; map[sourisI, sourisJ].appliquer(type_, this, moy, 16); for (int portee_ = 0; portee_ < size; portee_++) { for (int k = 0; k < portee_; k++) { if (sourisI + k >= 0 && sourisI + k < longueur && sourisJ + (portee_ - k) >= 0 && sourisJ + (portee_ - k) < largeur) { map[sourisI + k, sourisJ + (portee_ - k)].appliquer(type_, this, moy, 16 - portee_); } if (sourisI - k >= 0 && sourisI - k < longueur && sourisJ - (portee_ - k) >= 0 && sourisJ - (portee_ - k) < largeur) { map[sourisI - k, sourisJ - (portee_ - k)].appliquer(type_, this, moy, 16 - portee_); } if (sourisI + (portee_ - k) >= 0 && sourisI + (portee_ - k) < longueur && sourisJ - k >= 0 && sourisJ - k < largeur) { map[sourisI + (portee_ - k), sourisJ - k].appliquer(type_, this, moy, 16 - portee_); } if (sourisI - (portee_ - k) >= 0 && sourisI - (portee_ - k) < longueur && sourisJ + k >= 0 && sourisJ + k < largeur) { map[sourisI - (portee_ - k), sourisJ + k].appliquer(type_, this, moy, 16 - portee_); } } } } #endregion map[sourisI, sourisJ].appliquer(type_, this, r.Next(100), 16); for (int portee_ = 0; portee_ < size; portee_++) { for (int k = 0; k < portee_; k++) { if (sourisI + k >= 0 && sourisI + k < longueur && sourisJ + (portee_ - k) >= 0 && sourisJ + (portee_ - k) < largeur) { map[sourisI + k, sourisJ + (portee_ - k)].appliquer(type_, this, r.Next(100), 16 - portee_); } if (sourisI - k >= 0 && sourisI - k < longueur && sourisJ - (portee_ - k) >= 0 && sourisJ - (portee_ - k) < largeur) { map[sourisI - k, sourisJ - (portee_ - k)].appliquer(type_, this, r.Next(100), 16 - portee_); } if (sourisI + (portee_ - k) >= 0 && sourisI + (portee_ - k) < longueur && sourisJ - k >= 0 && sourisJ - k < largeur) { map[sourisI + (portee_ - k), sourisJ - k].appliquer(type_, this, r.Next(100), 16 - portee_); } if (sourisI - (portee_ - k) >= 0 && sourisI - (portee_ - k) < longueur && sourisJ + k >= 0 && sourisJ + k < largeur) { map[sourisI - (portee_ - k), sourisJ + k].appliquer(type_, this, r.Next(100), 16 - portee_); } } } } #endregion }
public void brille(e_toolSize taille_) { int i = -1; int j = -1; for (int p = 0; p < longueur; p++) { for (int q = 0; q < largeur; q++) { if (map[p, q].estSurvolee(new Rectangle(0, 0, 0, 0), camerax, cameray, direction)) { i = p; j = q; } } } foreach (Tile item in map) { item.estEnSurbrillance = false; } if (i != -1) { int size; switch (taille_) { case e_toolSize.XSmall: size = 1; break; case e_toolSize.Small: size = 2; break; case e_toolSize.Standard: size = 3; break; case e_toolSize.Medium: size = 4; break; case e_toolSize.Large: size = 5; break; case e_toolSize.XLarge: size = 6; break; default: size = 1; break; } map[i, j].estEnSurbrillance = true; for (int portee_ = 0; portee_ < size; portee_++) { for (int k = 0; k < portee_; k++) { if (i + k >= 0 && i + k < longueur && j + (portee_ - k) >= 0 && j + (portee_ - k) < largeur) { map[i + k, j + (portee_ - k)].estEnSurbrillance = true; } if (i - k >= 0 && i - k < longueur && j - (portee_ - k) >= 0 && j - (portee_ - k) < largeur) { map[i - k, j - (portee_ - k)].estEnSurbrillance = true; } if (i + (portee_ - k) >= 0 && i + (portee_ - k) < longueur && j - k >= 0 && j - k < largeur) { map[i + (portee_ - k), j - k].estEnSurbrillance = true; } if (i - (portee_ - k) >= 0 && i - (portee_ - k) < longueur && j + k >= 0 && j + k < largeur) { map[i - (portee_ - k), j + k].estEnSurbrillance = true; } } } } }
//Loohy public void UpdateEditeur(e_pinceau p_type_, e_toolSize p_taille_) { Camera(); #region Souris sourisI = -1; sourisJ = -1; for (int d = 0; d < 7; d++) { for (int i = (int)getCaseFromMouseAvecAltitude().X + 3; i >= (int)getCaseFromMouseAvecAltitude().X - 1; i--) { int j = (int)getCaseFromMouseAvecAltitude().Y - 1; if (i + d >= 0 && j + d >= 0 && i + d < longueur && j + d < largeur) { //if ((lastcamerax != camerax || lastcameray != cameray) && clicOrNot) //{ estCeLaSouris(i + d, j + d, new Rectangle(0, 0, 0, 0)); //} } } for (int j = (int)getCaseFromMouseAvecAltitude().Y + 3; j >= (int)getCaseFromMouseAvecAltitude().Y - 1; j--) { int i = (int)getCaseFromMouseAvecAltitude().X - 1; if (i + d >= 0 && j + d >= 0 && i + d < longueur && j + d < largeur) { //if ((lastcamerax != camerax || lastcameray != cameray) && clicOrNot) //{ estCeLaSouris(i + d, j + d, new Rectangle(0, 0, 0, 0)); //} } } } viderSurbrillance(); if (sourisI != -1) updatePinceau(p_type_, p_taille_); #endregion if (clicOrNot) { lastcamerax = camerax; lastcameray = cameray; } #region Clavier #region Back if (Keyboard.GetState().IsKeyDown(Keys.Back) && clicOrNot) { direction = (direction + 1) % 4; centrerSur(longueur / 2, largeur / 2); clicOrNot = false; } #endregion if (Keyboard.GetState().IsKeyUp(Keys.Back) && Keyboard.GetState().IsKeyUp(Keys.Up) && Keyboard.GetState().IsKeyUp(Keys.Down) && Keyboard.GetState().IsKeyUp(Keys.Left) && Keyboard.GetState().IsKeyUp(Keys.Right)) { clicOrNot = true; } #endregion }
//Loohy public override void Draw() { switch (state) { #region Ouvert case e_etatDeroulant.Ouvert: Contents.Draw("px", new Rectangle(rect.X, rect.Y + rect.Height, rect.Width, hauteur), Color.DarkRed); Rectangle rect2 = new Rectangle(rect.X, rect.Y + rect.Height, 110, (int)(Contents.MeasureString("S").Y + 2)); //hauteur = (int)(font.MeasureString("S").Y + 2) * 15; Color c = Color.Red; #region Type if (indexDico == 49)// { e_pinceau tableau = e_pinceau.Plaine; while (tableau != e_pinceau.Rien) { Contents.DrawString(Dico.langues[Dico.current][ToolText(tableau)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Contents.contientLaSouris(rect2)) { Contents.Draw("px", rect2, c); Contents.DrawString(Dico.langues[Dico.current][ToolText(tableau)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Mouse.GetState().LeftButton == ButtonState.Pressed) { tstate = tableau; //logBox_.ToLogBox("La brosse actuelle est : " + tstate.ToString()); state = e_etatDeroulant.Montant; } } rect2.Y += (int)(Contents.MeasureString("S").Y + 2); tableau++; } Contents.DrawString(Dico.langues[Dico.current][ToolText(tableau)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Contents.contientLaSouris(rect2)) { Contents.Draw("px", rect2, c); Contents.DrawString(Dico.langues[Dico.current][ToolText(tableau)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Mouse.GetState().LeftButton == ButtonState.Pressed) { tstate = tableau; //logBox_.ToLogBox("La brosse actuelle est : " + tstate.ToString()); state = e_etatDeroulant.Montant; } } } #endregion #region Size else if (indexDico == 50)// { e_toolSize tableur = e_toolSize.XSmall; while (tableur != e_toolSize.XLarge) { Contents.DrawString(Dico.langues[Dico.current][SizeText(tableur)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Contents.contientLaSouris(rect2)) { Contents.Draw("px", rect2, c); Contents.DrawString(Dico.langues[Dico.current][SizeText(tableur)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Mouse.GetState().LeftButton == ButtonState.Pressed) { tsize = tableur; //logBox_.ToLogBox("La taille de la brosse est : " + SizeText(tableur)); state = e_etatDeroulant.Montant; } } rect2.Y += (int)(Contents.MeasureString("S").Y + 2); tableur++; } Contents.DrawString(Dico.langues[Dico.current][SizeText(tableur)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Contents.contientLaSouris(rect2)) { Contents.Draw("px", rect2, c); Contents.DrawString(Dico.langues[Dico.current][SizeText(tableur)], new Rectangle(rect2.X, rect2.Y, 0, 0)); if (Mouse.GetState().LeftButton == ButtonState.Pressed) { tsize = tableur; //logBox_.ToLogBox("La taille de la brosse est : " + SizeText(tableur)); state = e_etatDeroulant.Montant; } } #endregion } goto default; #endregion #region Montant/Descendant case e_etatDeroulant.Montant: case e_etatDeroulant.Descendant: Contents.Draw("px", new Rectangle(rect.X, rect.Y + rect.Height, rect.Width, hauteur), Color.DarkRed); goto default; #endregion #region Bouton default: int s; if (indexDico == 49) { s = ToolText(tstate); } else { s = SizeText(tsize); } if (!Contents.contientLaSouris(base.rect)) { Contents.Draw("px", rect, Color.Gray); Contents.DrawStringInBoxCentered(Dico.langues[Dico.current][indexDico] + " : " + Dico.langues[Dico.current][s], rect, Color.Black); } else { Contents.Draw("px", rect, Color.DarkRed); Contents.DrawStringInBoxCentered(Dico.langues[Dico.current][indexDico] + " : " + Dico.langues[Dico.current][s], rect); } break; #endregion } }
//Loohy private int SizeText(e_toolSize size_) { int text = 0; switch (size_) { case e_toolSize.XSmall: text = 27; break; case e_toolSize.Small: text = 28; break; case e_toolSize.Standard: text = 29; break; case e_toolSize.Medium: text = 30; break; case e_toolSize.Large: text = 31; break; default: text = 32; break; } return text; }
//Loohy public void UpdateDeroulantNicoTuFaitPasChier(ref e_toolSize tsize_, ref e_pinceau tstate_) { switch (state) { case e_etatDeroulant.Ouvert: if (Contents.contientLaSouris(base.rect) && Mouse.GetState().LeftButton == ButtonState.Pressed) { state = e_etatDeroulant.Montant; } break; case e_etatDeroulant.Montant: hauteur -= 10; if (hauteur < 0) { hauteur = 0; state = e_etatDeroulant.Ferme; } break; case e_etatDeroulant.Descendant: hauteur += 10; if (indexDico == 49) { if (hauteur > Contents.MeasureString("S").Y * 16) { hauteur = (int)(Contents.MeasureString("S").Y + 2) * 16; state = e_etatDeroulant.Ouvert; } } else { if (hauteur > Contents.MeasureString("S").Y * 6) { hauteur = (int)(Contents.MeasureString("S").Y + 2) * 6; state = e_etatDeroulant.Ouvert; } } break; default: if (Contents.contientLaSouris(base.rect) && Mouse.GetState().LeftButton == ButtonState.Pressed) { state = e_etatDeroulant.Descendant; } break; } if (indexDico == 49) { tstate_ = tstate; } else { tsize_ = tsize; } }