44 |
|
|
45 |
class LevelWidget : public Widget { |
class LevelWidget : public Widget { |
46 |
public: |
public: |
47 |
LevelWidget(LevelPack *lp); |
LevelWidget(LevelPack *lp, int w, int h); |
48 |
bool manage (); |
bool manage (); |
49 |
int selected_level() const { return iselected; } |
int selected_level() const { return iselected; } |
50 |
|
|
142 |
|
|
143 |
// Variables. |
// Variables. |
144 |
Widget *newgame; |
Widget *newgame; |
145 |
|
Widget *playenigma; |
146 |
|
Widget *playoxyd; |
147 |
Widget *leveled; |
Widget *leveled; |
148 |
Widget *options; |
Widget *options; |
149 |
Widget *credits; |
Widget *credits; |
155 |
//---------------------------------------------------------------------- |
//---------------------------------------------------------------------- |
156 |
// LevelWidget implementation |
// LevelWidget implementation |
157 |
//---------------------------------------------------------------------- |
//---------------------------------------------------------------------- |
158 |
LevelWidget::LevelWidget(LevelPack *lp) |
LevelWidget::LevelWidget(LevelPack *lp, int w, int h) |
159 |
: level_pack(*lp), |
: level_pack(*lp), |
160 |
ifirst(0), iselected(0), |
ifirst(0), iselected(0), |
161 |
width(4), height(3), |
width(w), height(h), |
162 |
areas(), |
areas(), |
163 |
show_filenames_p(false), |
show_filenames_p(false), |
164 |
listener(0) |
listener(0) |
165 |
{} |
{} |
166 |
|
|
167 |
void LevelWidget::scroll_up(int nlines) |
void |
168 |
|
LevelWidget::scroll_up(int nlines) |
169 |
{ |
{ |
170 |
for (; nlines; --nlines) { |
for (; nlines; --nlines) { |
171 |
if (ifirst+width*height > (int)level_pack.levels.size()) |
if (ifirst+width*height >= (int)level_pack.levels.size()) |
172 |
break; |
break; |
173 |
ifirst += width; |
ifirst += width; |
174 |
if (iselected < ifirst) |
if (iselected < ifirst) |
175 |
iselected += width; |
iselected += width; |
|
redraw(); |
|
176 |
} |
} |
177 |
|
redraw(); |
178 |
} |
} |
179 |
|
|
180 |
void |
void |
186 |
ifirst -= width; |
ifirst -= width; |
187 |
if (iselected >= ifirst+width*height) |
if (iselected >= ifirst+width*height) |
188 |
iselected -= width; |
iselected -= width; |
|
redraw(); |
|
189 |
} |
} |
190 |
|
redraw(); |
191 |
} |
} |
192 |
|
|
193 |
void |
void |
204 |
const int hgap = 20, vgap=30; |
const int hgap = 20, vgap=30; |
205 |
|
|
206 |
const int x0 = get_x()+(get_w() - width*(imgw+hgap)+hgap)/2; |
const int x0 = get_x()+(get_w() - width*(imgw+hgap)+hgap)/2; |
207 |
const int y0 = get_y()+(get_h() - height*(imgh+vgap)+vgap)/2; //get_y(); //30; |
const int y0 = get_y()+(get_h() - height*(imgh+vgap))/2; //get_y(); //30; |
208 |
|
|
209 |
unsigned i=ifirst; |
unsigned i=ifirst; |
210 |
vector<LevelInfo> &levels = level_pack.levels; |
vector<LevelInfo> &levels = level_pack.levels; |
529 |
// Level menu |
// Level menu |
530 |
//---------------------------------------------------------------------- |
//---------------------------------------------------------------------- |
531 |
LevelMenu::LevelMenu(LevelPack *lp, unsigned ilevel_pack) |
LevelMenu::LevelMenu(LevelPack *lp, unsigned ilevel_pack) |
532 |
: newgame(new TextButton("New Game", this)), |
: newgame(new TextButton("Start Game", this)), |
533 |
quit(new TextButton("Quit", this)), |
quit(new TextButton("Back", this)), |
534 |
levelwidget(new LevelWidget(lp)), |
levelwidget(new LevelWidget(lp, 3, 4)), |
535 |
level_pack(lp) |
level_pack(lp) |
536 |
{ |
{ |
537 |
{ |
{ |
538 |
BuildHList hlist(this, Rect(30,10,100,28), 10); |
// BuildHList hlist(this, Rect(30,10,100,28), 10); |
539 |
|
BuildVList hlist(this, Rect(510,20,100,28), 5); |
540 |
pgup = hlist.add(new TextButton("Up", this)); |
pgup = hlist.add(new TextButton("Up", this)); |
541 |
pgdown = hlist.add(new TextButton("Down", this)); |
pgdown = hlist.add(new TextButton("Down", this)); |
542 |
start = hlist.add(new TextButton("Start", this)); |
start = hlist.add(new TextButton("Top", this)); |
543 |
end = hlist.add(new TextButton("End", this)); |
end = hlist.add(new TextButton("Bottom", this)); |
544 |
|
} |
545 |
|
{ |
546 |
|
BuildVList vlist(this, Rect(510,400,100,28), 5); |
547 |
|
// vlist.add(new TextButton("Timer on")); |
548 |
|
vlist.add(newgame); |
549 |
|
vlist.add(quit); |
550 |
} |
} |
551 |
#if 0 |
#if 0 |
552 |
HList *hlist = new HList; |
HList *hlist = new HList; |
558 |
y0=10; |
y0=10; |
559 |
add(new TextButton("Hard"), Rect(x0, y0, 100,28)); |
add(new TextButton("Hard"), Rect(x0, y0, 100,28)); |
560 |
add(new TextButton("Time Game"), Rect(x0+110, y0, 100,28)); |
add(new TextButton("Time Game"), Rect(x0+110, y0, 100,28)); |
|
add(new TextButton("Sound on"), Rect(x0+220, y0, 100,28)); |
|
|
add(new TextButton("Music on"), Rect(x0+330, y0, 100,28)); |
|
|
add(new TextButton("Mouse Speed"), Rect(x0+440, y0, 100,28)); |
|
561 |
#endif |
#endif |
562 |
|
|
563 |
// Add levelwidget at the center |
// Add levelwidget at the center |
564 |
add(levelwidget, Rect(0,48,640,480-48*2)); |
// add(levelwidget, Rect(0,48,640,480-48*2)); |
565 |
|
add(levelwidget, Rect(10,10,500,480)); |
566 |
levelwidget->set_listener(this); |
levelwidget->set_listener(this); |
567 |
} |
} |
568 |
|
|
646 |
MainMenu::MainMenu() |
MainMenu::MainMenu() |
647 |
{ |
{ |
648 |
BuildVList b(this, Rect((640-150)/2,200,150,40), 5); |
BuildVList b(this, Rect((640-150)/2,200,150,40), 5); |
649 |
newgame = b.add(new TextButton("New Game", this)); |
newgame = 0; //b.add(new TextButton("New Game", this)); |
650 |
leveled = b.add(new TextButton("Editor", this)); |
playenigma = b.add(new TextButton("Play Enigma", this)); |
651 |
|
playoxyd = b.add(new TextButton("Play Oxyd & Co", this)); |
652 |
|
leveled = 0; //b.add(new TextButton("Editor", this)); |
653 |
options = b.add(new TextButton("Options", this)); |
options = b.add(new TextButton("Options", this)); |
654 |
credits = b.add(new TextButton("Credits", this)); |
credits = b.add(new TextButton("Credits", this)); |
655 |
quit = b.add(new TextButton("Quit", this)); |
quit = b.add(new TextButton("Quit", this)); |
678 |
LevelPackMenu m; |
LevelPackMenu m; |
679 |
m.center(video::GetScreen()); |
m.center(video::GetScreen()); |
680 |
m.manage(video::GetScreen()); |
m.manage(video::GetScreen()); |
681 |
} else if (w == credits) { |
} |
682 |
|
else if (w == playenigma) { |
683 |
|
LevelMenu m(enigma::LevelPacks[0], 0); |
684 |
|
m.manage(video::GetScreen()); |
685 |
|
invalidate_all(); |
686 |
|
} |
687 |
|
else if (w == playoxyd) { |
688 |
|
LevelMenu m(enigma::LevelPacks[1], 0); |
689 |
|
m.manage(video::GetScreen()); |
690 |
|
invalidate_all(); |
691 |
|
} |
692 |
|
else if (w == credits) { |
693 |
show_credits (); |
show_credits (); |
694 |
} else if (w == options) { |
} else if (w == options) { |
695 |
GUI_OptionsMenu(); |
GUI_OptionsMenu(); |