Jypeli  9
The simple game programming library
YesNoWindow.cs
Siirry tämän tiedoston dokumentaatioon.
1 #region MIT License
2 /*
3  * Copyright (c) 2009-2011 University of Jyväskylä, Department of Mathematical
4  * Information Technology.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #endregion
25 
26 /*
27  * Authors: Tomi Karppinen, Tero Jäntti
28  */
29 
30 using System;
31 
32 namespace Jypeli
33 {
38  {
42  public event Action Yes;
43 
47  public event Action No;
48 
49  private void OnYes()
50  {
51  if ( Yes != null ) Yes();
52  }
53 
54  private void OnNo()
55  {
56  if ( No != null ) No();
57  }
58 
63  public YesNoWindow( string question )
64  : this( question, "Yes", "No" )
65  {
66  }
67 
68  public YesNoWindow( string question, string yesString, string noString )
69  : base( question, yesString, noString )
70  {
71  AddItemHandler( 0, OnYes );
72  AddItemHandler( 1, OnNo );
73 
74  Buttons[0].Color = Color.Green;
76 
77  DefaultCancel = 1;
78 
79  AddedToGame += AddControls;
80  }
81 
82  private void AddControls()
83  {
84  var l1 = Buttons[0].AddShortcut(Button.A);
85  var l2 = Buttons[1].AddShortcut(Button.B);
86  associatedListeners.AddRange(l1);
87  associatedListeners.AddRange(l2);
88  }
89  }
90 }
Jypeli.YesNoWindow.Yes
Action Yes
Tapahtuu kun käyttäjä valitsee "kyllä"-vaihtoehdon.
Definition: YesNoWindow.cs:42
Jypeli.MultiSelectWindow
Ikkuna, joka antaa käyttäjän valita yhden annetuista vaihtoehdoista.
Definition: MultiSelectWindow.cs:12
Jypeli.YesNoWindow.YesNoWindow
YesNoWindow(string question, string yesString, string noString)
Definition: YesNoWindow.cs:68
Jypeli
Definition: Automobile.cs:5
Jypeli.MultiSelectWindow.Buttons
PushButton[] Buttons
Painonappulat järjestyksessä.
Definition: MultiSelectWindow.cs:32
Jypeli.MultiSelectWindow.DefaultCancel
int DefaultCancel
Mitä valitaan kun käyttäjä painaa esc tai takaisin-näppäintä. Laittomalla arvolla (esim....
Definition: MultiSelectWindow.cs:59
Jypeli.YesNoWindow.YesNoWindow
YesNoWindow(string question)
Luo uuden kyselyikkunan.
Definition: YesNoWindow.cs:63
Jypeli.Color.Green
static readonly Color Green
Vihreä.
Definition: Color.cs:648
Jypeli.PushButton.AddShortcut
Listener AddShortcut(Key key)
Lisää pikanäppäimen napille.
Definition: PushButton.cs:348
Jypeli.Color.DarkRed
static readonly Color DarkRed
Tumma punainen.
Definition: Color.cs:598
Jypeli.YesNoWindow.No
Action No
Tapahtuu kun käyttäjä valitsee "ei"-vaihtoehdon.
Definition: YesNoWindow.cs:47
Jypeli.Button
Button
Definition: Button.cs:35
Jypeli.PushButton.Color
override Color Color
Definition: PushButton.cs:127
Jypeli.MultiSelectWindow.AddItemHandler
void AddItemHandler(int item, Action handler)
Definition: MultiSelectWindow.cs:201
Jypeli.YesNoWindow
Ikkuna, joka kysyy käyttäjältä kyllä tai ei -kysymyksen.
Definition: YesNoWindow.cs:38
Jypeli.Color
Väri.
Definition: Color.cs:13
Jypeli.YesNoWindow.OnYes
void OnYes()
Definition: YesNoWindow.cs:49
System
Definition: CFFauxAttributes.cs:29
Jypeli.Widget.associatedListeners
List< Listener > associatedListeners
Tähän listaan lisätyt kuuntelijat tuhotaan automaattisesti kun Widget poistetaan pelistä.
Definition: Control.cs:14
Jypeli.YesNoWindow.OnNo
void OnNo()
Definition: YesNoWindow.cs:54
Jypeli.YesNoWindow.AddControls
void AddControls()
Definition: YesNoWindow.cs:82