Jypeli  9
The simple game programming library
EasyHighScore.cs
Siirry tämän tiedoston dokumentaatioon.
1 using System;
2 
3 namespace Jypeli.Widgets
4 {
8  public class EasyHighScore
9  {
11  string fileName;
12 
16  public HighScoreWindow HighScoreWindow { get; private set; }
17 
22  {
23  get { return HighScoreWindow.NameInputWindow; }
24  }
25 
29  public int MaxNameLength
30  {
31  get { return HighScoreWindow.MaxNameLength; }
32  set { HighScoreWindow.MaxNameLength = value; }
33  }
34 
38  public string Text
39  {
40  get { return HighScoreWindow.Message.Text; }
41  set { HighScoreWindow.Message.Text = value; }
42  }
43 
47  public string EnterText
48  {
51  }
52 
56  public Color Color
57  {
58  get
59  {
60  return HighScoreWindow.Color;
61  }
62  set
63  {
64  HighScoreWindow.Color = value;
65  }
66  }
67 
74  public EasyHighScore(string fileName, int places, string defaultName)
75  {
76  this.score = new ScoreList(places, false, 0, defaultName);
77  this.fileName = fileName;
80  }
81 
87  public EasyHighScore(string fileName, int places)
88  {
89  this.score = new ScoreList(places, false, 0);
90  this.fileName = fileName;
93  }
94 
99  public EasyHighScore(int places)
100  : this(Game.Name + "_score.xml", places)
101  {
102  }
103 
107  public EasyHighScore()
108  : this(Game.Name + "_score.xml", 10)
109  {
110  }
111 
113  {
114  Vector entrySize = Font.Default.MeasureSize("XXXXXXXXXXXXXXXXXXXXXXXXX");
115  int width = (int)Math.Min(Game.Screen.Width - 30.0, entrySize.X);
116  int height = (int)Math.Min(Game.Screen.Height - 30.0, entrySize.Y * 20.0);
117  // TODO ^ 20.0 is just a silly magic number, no real logic behind it
118  // it seems to work well enough with both the medium and huge fonts, so it's
119  // a fitting temporary solution until someone has the time to figure out the
120  // mess of layouts and HighScoreWindow / ScoreListWidget and the classes
121  // they're derived from
122 
123  HighScoreWindow = new HighScoreWindow(width, height, "High score", score);
124  }
125 
129  public void Show()
130  {
132  }
133 
137  public void Clear()
138  {
139  score = new ScoreList( score.Count, score.Reverse, 0 );
141  }
142 
148  public void EnterAndShow(double newScore)
149  {
151  HighScoreWindow.ShowNameInput( newScore );
153  }
154 
155  private void SaveData(Window sender)
156  {
159  }
160 
161  private void LoadData()
162  {
164  }
165  }
166 }
Jypeli.Widgets.EasyHighScore.EasyHighScore
EasyHighScore(string fileName, int places, string defaultName)
Luo uuden parhaiden pisteiden ikkunan.
Definition: EasyHighScore.cs:74
Jypeli.Vector.Min
static Vector Min(params Vector[] vectors)
Palauttaa lyhimmän vektorin.
Definition: Vector.cs:231
Jypeli.CustomQueryWindow.Message
Label Message
Viesti tai kysymys.
Definition: CustomQueryWindow.cs:42
Jypeli.Widgets.EasyHighScore.SaveData
void SaveData(Window sender)
Definition: EasyHighScore.cs:155
Jypeli.Vector.X
double X
Definition: Vector.cs:312
Jypeli.Widgets.HighScoreWindow.MaxNameLength
int MaxNameLength
Pisin mahdollinen nimi, jonka listaan voi syöttää.
Definition: HighScoreWindow.cs:60
Jypeli.Widgets.EasyHighScore.EnterAndShow
void EnterAndShow(double newScore)
Näyttää parhaat pisteet, ja jos annetut pisteet riittävät, antaa syöttää nimen listalle....
Definition: EasyHighScore.cs:148
Jypeli.Widgets.EasyHighScore.EasyHighScore
EasyHighScore(string fileName, int places)
Luo uuden parhaiden pisteiden ikkunan.
Definition: EasyHighScore.cs:87
Jypeli.ScoreList.Reverse
bool Reverse
Käänteinen järjestys, ts. pienempi tulos on parempi.
Definition: ScoreList.cs:100
Jypeli.ScoreList.Count
int Count
Kuinka monta nimeä listalle mahtuu.
Definition: ScoreList.cs:54
Jypeli.CustomQueryWindow.Color
override Color Color
Definition: CustomQueryWindow.cs:55
Jypeli.Font.Default
static readonly Font Default
Oletusfontti.
Definition: Font.cs:30
Jypeli.ScoreList
Parhaiden pisteiden lista.
Definition: ScoreList.cs:42
Jypeli.Widgets.HighScoreWindow.NameInputWindow
InputWindow NameInputWindow
Nimensyöttöikkuna.
Definition: HighScoreWindow.cs:46
Jypeli.Widgets.EasyHighScore.HighScoreWindow
HighScoreWindow HighScoreWindow
Listaikkuna.
Definition: EasyHighScore.cs:16
Jypeli.FileManager.Save
void Save(object obj, string fileName)
Definition: Serialization.cs:64
Jypeli.Widgets.EasyHighScore.Clear
void Clear()
Tyhjentää parhaat pisteet.
Definition: EasyHighScore.cs:137
Jypeli.InputWindow
Ikkuna, joka sisältää käyttäjän määrittelemän kysymyksen, tekstinsyöttökentän ja OK-painikkeen....
Definition: InputWindow.cs:43
Jypeli.Game.DataStorage
static FileManager DataStorage
Tietovarasto, johon voi tallentaa tiedostoja pidempiaikaisesti. Sopii esimerkiksi pelitilanteen lataa...
Definition: Game.cs:101
Jypeli.ScreenView.Width
double Width
Näytön leveys x-suunnassa.
Definition: View.cs:222
Jypeli.Game.AssertInitialized
static void AssertInitialized(Action actionMethod)
Suorittaa aliohjelman kun peli on varmasti alustettu.
Definition: DelayedActions.cs:53
Jypeli.Widgets.EasyHighScore.LoadData
void LoadData()
Definition: EasyHighScore.cs:161
Jypeli.Widgets.HighScoreWindow.ShowNameInput
void ShowNameInput(double newScore)
Näyttää nimensyöttöikkunan.
Definition: HighScoreWindow.cs:138
Jypeli.Widgets.EasyHighScore.Text
string Text
Pisteikkunan teksti.
Definition: EasyHighScore.cs:39
Jypeli.Widgets.EasyHighScore.EnterText
string EnterText
Nimensyöttöikkunan teksti.
Definition: EasyHighScore.cs:48
Jypeli.Game.Instance
static Game Instance
Käynnissä olevan pelin pääolio.
Definition: Game.cs:90
Jypeli.Widgets.EasyHighScore
Helpompikäyttöinen parhaiden pisteiden lista.
Definition: EasyHighScore.cs:9
Jypeli.Game.Add
void Add(Light light)
Lisää valon peliin. Nykyisellään valoja voi olla ainoastaan yksi kappale. Toistaiseksi ei tuettu Wind...
Definition: Effects.cs:27
Jypeli.Font.MeasureSize
Vector MeasureSize(string str)
Laskee tekstin koon fontilla.
Definition: Font.cs:282
Jypeli.Widgets.EasyHighScore.InitHSWindow
void InitHSWindow()
Definition: EasyHighScore.cs:112
Jypeli.ScreenView.Height
double Height
Näytön korkeus y-suunnassa.
Definition: View.cs:235
Jypeli.Widgets.EasyHighScore.EasyHighScore
EasyHighScore()
Luo uuden parhaiden pisteiden ikkunan kymmenellä pistesijalla.
Definition: EasyHighScore.cs:107
Jypeli.Game.Screen
static ScreenView Screen
Näytön dimensiot, eli koko ja reunat.
Definition: Graphics.cs:90
Jypeli.Widgets.EasyHighScore.MaxNameLength
int MaxNameLength
Pisin sallittu nimen pituus.
Definition: EasyHighScore.cs:30
Jypeli.Widgets.EasyHighScore.Show
void Show()
Näyttää parhaat pisteet.
Definition: EasyHighScore.cs:129
Jypeli.Widgets.EasyHighScore.NameInputWindow
InputWindow NameInputWindow
Nimensyöttöikkuna.
Definition: EasyHighScore.cs:22
Jypeli.Color
Väri.
Definition: Color.cs:13
Jypeli.Widgets
Definition: Background.cs:34
Jypeli.Vector
2D-vektori.
Definition: Vector.cs:59
System
Definition: CFFauxAttributes.cs:29
Jypeli.Window
Ikkuna.
Definition: Window.cs:37
Jypeli.Font
Fontti.
Definition: Font.cs:23
Jypeli.Widgets.HighScoreWindow
Parhaiden pisteiden ikkuna.
Definition: HighScoreWindow.cs:39
Jypeli.Widgets.EasyHighScore.fileName
string fileName
Definition: EasyHighScore.cs:11
Jypeli.Label.Text
virtual string Text
Teksti.
Definition: Label.cs:92
Jypeli.Game
Definition: Content.cs:46
Jypeli.Widgets.EasyHighScore.EasyHighScore
EasyHighScore(int places)
Luo uuden parhaiden pisteiden ikkunan.
Definition: EasyHighScore.cs:99
Jypeli.Vector.Y
double Y
Definition: Vector.cs:313
Jypeli.Widgets.EasyHighScore.score
ScoreList score
Definition: EasyHighScore.cs:10