[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-cvs] enigma/src menus.cc,1.75,1.76
From: |
Daniel Heck <address@hidden> |
Subject: |
[Enigma-cvs] enigma/src menus.cc,1.75,1.76 |
Date: |
Sun, 16 Nov 2003 19:32:52 +0000 |
Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv17775/src
Modified Files:
menus.cc
Log Message:
Use new options code. Redesigned options menu to
use buttons with labels instead of wordy button texts. Removed
"Manual" entry from main menu and added "Editor" entry.
Index: menus.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/menus.cc,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -d -r1.75 -r1.76
*** menus.cc 12 Nov 2003 09:35:02 -0000 1.75
--- menus.cc 16 Nov 2003 19:32:50 -0000 1.76
***************
*** 18,21 ****
--- 18,22 ----
* $Id$
*/
+ #include "main.hh"
#include "video.hh"
#include "menus.hh"
***************
*** 36,40 ****
using namespace enigma;
- using namespace options;
using namespace gui;
using namespace px;
--- 37,40 ----
***************
*** 44,48 ****
#include "menus_internal.hh"
-
/* -------------------- Level Pack Menu -------------------- */
--- 44,47 ----
***************
*** 142,146 ****
ifirst = 0;
level_pack = lp;
! oxyd::ChangeSoundset(options::SoundSet,
level_pack->get_default_SoundSet());
cache.clear();
preview_cache.clear();
--- 141,145 ----
ifirst = 0;
level_pack = lp;
! oxyd::ChangeSoundset(options::GetInt("SoundSet"),
level_pack->get_default_SoundSet());
cache.clear();
preview_cache.clear();
***************
*** 151,155 ****
void LevelWidget::next_unsolved() {
! unsigned next = NextLevel(level_pack, iselected, max_available, true,
options::TimeHunting);
if (next)
--- 150,155 ----
void LevelWidget::next_unsolved() {
! unsigned next = NextLevel(level_pack, iselected, max_available, true,
! options::GetBool("TimeHunting"));
if (next)
***************
*** 159,202 ****
}
- namespace levels {
- void get_best_times(const LevelInfo *li, const LevelStatus *ls,
- int& par_time, int& best_user_time,
string *best_par_name)
- {
- assert(li);
-
- par_time = options::Difficulty == DIFFICULTY_HARD
- ? li->best_time_normal
- : li->best_time_easy;
-
- if (par_time == LevelInfo::DEFAULT_TIME)
- par_time = -1;
-
- if (best_par_name) {
- *best_par_name = options::Difficulty == DIFFICULTY_HARD
- ? li->best_time_normal_by
- : li->best_time_easy_by;
- }
- best_user_time = -1;
-
- if (ls) {
- if (li->has_easymode) {
- if ((ls->finished&options::Difficulty)>0) {
- const int& what_time = options::Difficulty ==
DIFFICULTY_HARD ? ls->time_hard : ls->time_easy;
- if (what_time>0) best_user_time = what_time;
- }
- }
- else {
- if (ls->finished) {
- if (ls->time_hard > 0) best_user_time = ls->time_hard;
- if (ls->time_easy > 0 && (ls->time_easy<best_user_time ||
best_user_time<0))
- best_user_time = ls->time_easy;
- }
- }
- if (ls->solved_revision<li->revision)
- best_user_time = -1;
- }
- }
- }
-
void
LevelWidget::draw (px::GC &gc, const px::Rect &r)
--- 159,162 ----
***************
*** 224,227 ****
--- 184,190 ----
unsigned i=ifirst; // level index
+
+ LevelStatus levelstat;
+
for (int y=0; y<height; y++)
{
***************
*** 257,261 ****
img = cache.get(enigma::FindDataFile(fname));
}
! if (!img && !Nozoom) {
img = preview_cache.getPreview(level_pack, i);
if (!img)
--- 220,224 ----
img = cache.get(enigma::FindDataFile(fname));
}
! if (!img && !enigma::Nozoom) {
img = preview_cache.getPreview(level_pack, i);
if (!img)
***************
*** 267,277 ****
bool par_reached = false;
! if (LevelStatus *ls = GetLevelStatus(level_pack->get_name(),
levelinfo->filename)) {
! finished = ls->finished;
if (finished) {
! level_changed = level_pack->get_revision_number(i) >
ls->solved_revision;
! int par_time, best_user_time;
! get_best_times(levelinfo, ls, par_time, best_user_time,
0);
par_reached = best_user_time>0 && (par_time<0 ||
best_user_time <= par_time);
}
--- 230,242 ----
bool par_reached = false;
! if (options::GetLevelStatus(level_pack->get_name(),
levelinfo->filename,
! levelstat))
! {
! finished = levelstat.finished;
if (finished) {
! level_changed = level_pack->get_revision_number(i) >
levelstat.solved_revision;
! int par_time = level_pack->get_par_time (i,
GetDifficulty());
! int best_user_time = level_pack->get_best_user_time (i);
par_reached = best_user_time>0 && (par_time<0 ||
best_user_time <= par_time);
}
***************
*** 282,286 ****
if (img) {
blit (gc, imgx, imgy, img);
! if (finished >= options::Difficulty || (finished > 0 &&
!levelinfo->has_easymode)) {
blit (gc, imgx, imgy, img_solved); // Shade completed
levels
}
--- 247,251 ----
if (img) {
blit (gc, imgx, imgy, img);
! if (finished >= GetDifficulty() || (finished > 0 &&
!levelinfo->has_easymode)) {
blit (gc, imgx, imgy, img_solved); // Shade completed
levels
}
***************
*** 294,300 ****
// Draw solved/changed icons on top of level preview
! if (finished && (!levelinfo->has_easymode ||
(finished&options::Difficulty) != 0)) {
blit (gc, imgx, imgy,
! options::Difficulty == DIFFICULTY_HARD ? img_hard :
img_easy);
}
--- 259,265 ----
// Draw solved/changed icons on top of level preview
! if (finished && (!levelinfo->has_easymode || (finished&
GetDifficulty()) != 0)) {
blit (gc, imgx, imgy,
! GetDifficulty() == DIFFICULTY_HARD ? img_hard :
img_easy);
}
***************
*** 423,431 ****
case SDLK_u: { // set state to "unsolved"
! const LevelInfo *info = level_pack->get_info(iselected);
! LevelStatus *status = GetLevelStatus(level_pack->get_name(),
info->filename);
!
! if (status && status->finished) {
! status->finished = 0;
redraw();
}
--- 388,395 ----
case SDLK_u: { // set state to "unsolved"
! LevelStatus levelstat;
! if (level_pack->get_status (iselected, levelstat) &&
levelstat.finished) {
! levelstat.finished = 0;
! level_pack->set_status (iselected, levelstat);
redraw();
}
***************
*** 443,447 ****
case SDLK_F1: {
px::Screen *screen = video::GetScreen();
! if (options::TimeHunting)
helptext_levelmenu[5] = "Select next non-par level";
else
--- 407,411 ----
case SDLK_F1: {
px::Screen *screen = video::GetScreen();
! if (options::GetBool("TimeHunting"))
helptext_levelmenu[5] = "Select next non-par level";
else
***************
*** 485,504 ****
{
class MouseSpeedButton : public ValueButton {
! int get_value() const { return int(MouseSpeed+.5); }
! void set_value(int value) { MouseSpeed = value; }
string build_text(int value) const {
! return strf("Mouse speed: %d", value);
}
public:
MouseSpeedButton()
! : ValueButton("", minMouseSpeed, maxMouseSpeed)
{ update(); }
};
class SoundVolumeButton : public ValueButton {
! int get_value() const { return int(0.5+SoundVolume*10.0); }
void set_value(int value) {
! SoundVolume = value/10.0;
sound::UpdateVolume();
}
--- 449,474 ----
{
class MouseSpeedButton : public ValueButton {
! int get_value() const {
! return static_cast<int>(enigma::GetMouseSpeed() + 0.5);
! }
! void set_value(int value) {
! enigma::SetMouseSpeed (value);
! }
string build_text(int value) const {
! return strf("%d", value);
}
public:
MouseSpeedButton()
! : ValueButton("", enigma::MIN_MouseSpeed, enigma::MAX_MouseSpeed)
{ update(); }
};
class SoundVolumeButton : public ValueButton {
! int get_value() const {
! return static_cast<int>(0.5 +
options::GetDouble("SoundVolume")*10.0);
! }
void set_value(int value) {
! options::SetOption("SoundVolume", value/10.0);
sound::UpdateVolume();
}
***************
*** 506,513 ****
string build_text(int value) const {
if (value == 0) {
! return "Sound off";
}
else {
! return strf("Sound vol: %d", value);
}
}
--- 476,483 ----
string build_text(int value) const {
if (value == 0) {
! return "muted";
}
else {
! return strf("%d", value);
}
}
***************
*** 517,533 ****
class MusicVolumeButton : public ValueButton {
! int get_value() const { return int(0.5+MusicVolume*10.0); }
void set_value(int value) {
! MusicVolume = value/10.0;
sound::UpdateVolume();
}
string build_text(int value) const {
! if (value == 0) {
! return "Music off";
! }
! else {
! return strf("Music vol: %d", value);
! }
}
public:
--- 487,503 ----
class MusicVolumeButton : public ValueButton {
! int get_value() const {
! return static_cast<int> (0.5 +
options::GetDouble("MusicVolume")*10.0);
! }
void set_value(int value) {
! options::SetOption("MusicVolume", value/10.0);
sound::UpdateVolume();
}
string build_text(int value) const {
! if (value == 0)
! return "muted";
! else
! return strf("%d", value);
}
public:
***************
*** 537,552 ****
class StereoButton : public ValueButton {
! int get_value() const { return StereoSeparation == 0 ? 0 :
(StereoSeparation > 0 ? 1 : -1); }
void set_value(int value) {
! if (value == 0) StereoSeparation = 0.0;
! else if (value > 0) StereoSeparation = 10.0;
! else StereoSeparation = -10.0;
}
string build_text(int value) const {
switch (value) {
! case -1: return "Stereo r-l";
! case 0: return "Mono";
! case 1: return "Stereo l-r";
}
assert(0);
--- 507,531 ----
class StereoButton : public ValueButton {
! int get_value() const {
! double separation = options::GetDouble("StereoSeparation");
! if (separation == 0)
! return 0;
! else
! return (separation > 0) ? 1 : -1;
! }
void set_value(int value) {
! if (value == 0)
! options::SetOption("StereoSeparation", 0.0);
! else if (value > 0)
! options::SetOption("StereoSeparation", 10.0);
! else
! options::SetOption("StereoSeparation", -10.0);
}
string build_text(int value) const {
switch (value) {
! case -1: return "reversed";
! case 0: return "mono";
! case 1: return "normal";
}
assert(0);
***************
*** 560,564 ****
class InGameMusicButton : public TextButton {
void update() {
! if (InGameMusic)
set_text("Music in game");
else
--- 539,543 ----
class InGameMusicButton : public TextButton {
void update() {
! if (options::GetBool("InGameMusic"))
set_text("Music in game");
else
***************
*** 566,574 ****
}
void on_action(Widget *) {
! InGameMusic = ! InGameMusic;
! if( InGameMusic)
! sound::PlayMusic( LevelMusicFile.c_str());
else
! sound::StopMusic( LevelMusicFile.c_str());
update();
}
--- 545,554 ----
}
void on_action(Widget *) {
! bool newval = ! options::GetBool("InGameMusic");
! options::SetOption ("InGameMusic", newval);
! if (newval)
! sound::PlayMusic (options::GetString("LevelMusicFile"));
else
! sound::StopMusic (options::GetString("LevelMusicFile"));
update();
}
***************
*** 579,583 ****
class SoundSetButton : public ValueButton {
! int get_value() const { return SoundSet; }
bool hasSoundSet(int value) {
--- 559,563 ----
class SoundSetButton : public ValueButton {
! int get_value() const { return options::GetInt("SoundSet"); }
bool hasSoundSet(int value) {
***************
*** 587,598 ****
void set_value(int value) {
! int old = SoundSet;
! SoundSet = value;
! if (!hasSoundSet(SoundSet)) {
! if (old < SoundSet) inc_value(1);
! else inc_value(-1);
return;
}
! oxyd::ChangeSoundset(SoundSet, -1);
}
string build_text(int value) const {
--- 567,580 ----
void set_value(int value) {
! int old = options::GetInt("SoundSet");
! options::SetOption("SoundSet", value);
! if (!hasSoundSet(options::GetInt("SoundSet"))) {
! if (old < options::GetInt("SoundSet"))
! inc_value(1);
! else
! inc_value(-1);
return;
}
! oxyd::ChangeSoundset(options::GetInt("SoundSet"), -1);
}
string build_text(int value) const {
***************
*** 602,606 ****
case 1: sound_set = "Enigma"; break;
default :
! switch (OxydVersion(SoundSet-2)) {
case OxydVersion_Oxyd1: sound_set = "Oxyd"; break;
case OxydVersion_OxydMagnum: sound_set = "Magnum"; break;
--- 584,588 ----
case 1: sound_set = "Enigma"; break;
default :
! switch (OxydVersion(options::GetInt("SoundSet")-2)) {
case OxydVersion_Oxyd1: sound_set = "Oxyd"; break;
case OxydVersion_OxydMagnum: sound_set = "Magnum"; break;
***************
*** 623,633 ****
class SkipSolvedButton : public TextButton {
void update() {
! if (SkipSolvedLevels)
! set_text("Skip solved levels");
else
! set_text("Play all levels");
}
void on_action(Widget *) {
! SkipSolvedLevels = ! SkipSolvedLevels;
update();
}
--- 605,616 ----
class SkipSolvedButton : public TextButton {
void update() {
! if (options::GetBool("SkipSolvedLevels"))
! set_text("Yes");
else
! set_text("No");
}
void on_action(Widget *) {
! options::SetOption("SkipSolvedLevels",
! ! options::GetBool("SkipSolvedLevels"));
update();
}
***************
*** 638,648 ****
class TimeHuntButton : public TextButton {
void update() {
! if (TimeHunting)
! set_text("Time-Hunt");
else
! set_text("Normal timing");
}
void on_action(Widget *) {
! TimeHunting = ! TimeHunting;
update();
}
--- 621,631 ----
class TimeHuntButton : public TextButton {
void update() {
! if (options::GetBool("TimeHunting"))
! set_text("Yes");
else
! set_text("No");
}
void on_action(Widget *) {
! options::SetOption("TimeHunting",
!options::GetBool("TimeHunting"));
update();
}
***************
*** 653,661 ****
class VideoModeButton : public TextButton {
video::VideoModes get_mode() {
! int mode = Clamp(options::VideoMode, 0, int(video::VM_COUNT));
return static_cast<video::VideoModes>(mode);
}
void update() {
! string txt ("Video: ");
txt += video::GetInfo(get_mode())->name;
set_text(txt);
--- 636,644 ----
class VideoModeButton : public TextButton {
video::VideoModes get_mode() {
! int mode = Clamp(options::GetInt("VideoMode"), 0,
int(video::VM_COUNT));
return static_cast<video::VideoModes>(mode);
}
void update() {
! string txt; // ("Video: ");
txt += video::GetInfo(get_mode())->name;
set_text(txt);
***************
*** 664,668 ****
int mode = get_mode() + 1;
if (mode >= video::VM_COUNT) mode = 0;
! options::VideoMode = mode;
options::MustRestart = true;
update();
--- 647,651 ----
int mode = get_mode() + 1;
if (mode >= video::VM_COUNT) mode = 0;
! options::SetOption("VideoMode", mode);
options::MustRestart = true;
update();
***************
*** 681,687 ****
void FullscreenButton::on_action(Widget *)
{
! bool old = FullScreen;
! FullScreen = video::ToggleFullscreen();
! if (old != FullScreen)
update();
else
--- 664,670 ----
void FullscreenButton::on_action(Widget *)
{
! bool old = options::GetBool("FullScreen");
! options::SetOption("FullScreen", video::ToggleFullscreen());
! if (old != options::GetBool("FullScreen"))
update();
else
***************
*** 690,697 ****
void FullscreenButton::update() {
! if (FullScreen > 0)
! set_text("Fullscreen");
else
! set_text("Window");
}
--- 673,680 ----
void FullscreenButton::update() {
! if (options::GetBool("FullScreen") > 0)
! set_text("Yes");
else
! set_text("No");
}
***************
*** 702,706 ****
void DifficultyButton::update() {
! if (Difficulty == DIFFICULTY_EASY)
set_text("Difficulty: Easy");
else
--- 685,689 ----
void DifficultyButton::update() {
! if (GetDifficulty() == DIFFICULTY_EASY)
set_text("Difficulty: Easy");
else
***************
*** 709,713 ****
void DifficultyButton::on_action(Widget *) {
! Difficulty = (DIFFICULTY_EASY+DIFFICULTY_HARD)-Difficulty;
options::MustRestartLevel = true;
update();
--- 692,697 ----
void DifficultyButton::on_action(Widget *) {
! int newdifficulty = (DIFFICULTY_EASY+DIFFICULTY_HARD) - GetDifficulty();
! options::SetOption("Difficulty", newdifficulty);;
options::MustRestartLevel = true;
update();
***************
*** 717,720 ****
--- 701,724 ----
/* -------------------- Options Menu -------------------- */
+ class BuildTable {
+ Container *container;
+ int columns;
+ int current_column;
+ int rowheight;
+
+ public:
+ BuildTable (Container *container_, int columns_, int rowheight_)
+ : container(container_) ,
+ columns (columns_),
+ current_column (0),
+ rowheight (rowheight_)
+ {}
+
+ void add (Widget *w) {
+
+ }
+ };
+
+
OptionsMenu::OptionsMenu(px::Surface *background_)
: back(new TextButton("Back", this)),
***************
*** 726,734 ****
const int spacing = 5;
const int big_spacing = 60;
! const int but_width = 150;
! const int but_height = 40;
BuildVList left (this, Rect(0, 0, but_width, but_height), spacing);
! BuildVList right(this, Rect(but_width+big_spacing, 0, but_width,
but_height), spacing);
left.add (fullscreen);
--- 730,746 ----
const int spacing = 5;
const int big_spacing = 60;
! const int label_width = 150;
! const int but_width = 80;
! const int but_height = 30;
+ BuildVList leftlabels (this, Rect(-label_width, 0, label_width,
but_height), spacing);
BuildVList left (this, Rect(0, 0, but_width, but_height), spacing);
! BuildVList rightlabels (this, Rect(but_width+big_spacing, 0, label_width,
but_height), spacing);
! BuildVList right(this, Rect(but_width+big_spacing+label_width, 0,
but_width, but_height), spacing);
! leftlabels.add (new Label("Fullscreen: ", HALIGN_RIGHT));
! leftlabels.add (new Label("Mouse speed: ", HALIGN_RIGHT));
! leftlabels.add (new Label("Skip solved levels: ", HALIGN_RIGHT));
! leftlabels.add (new Label("Time hunt: ", HALIGN_RIGHT));
! leftlabels.add (new Label("Video Mode: ", HALIGN_RIGHT));
left.add (fullscreen);
***************
*** 736,742 ****
left.add (new SkipSolvedButton);
left.add (new TimeHuntButton);
- // left.add (new DifficultyButton);
left.add (new VideoModeButton);
right.add (new SoundVolumeButton);
right.add (new SoundSetButton);
--- 748,759 ----
left.add (new SkipSolvedButton);
left.add (new TimeHuntButton);
left.add (new VideoModeButton);
+
+ rightlabels.add (new Label("Sound volume: ", HALIGN_RIGHT));
+ rightlabels.add (new Label("Sound set: ", HALIGN_RIGHT));
+ rightlabels.add (new Label("Music volume: ", HALIGN_RIGHT));
+ rightlabels.add (new Label("Stereo: ", HALIGN_RIGHT));
+
right.add (new SoundVolumeButton);
right.add (new SoundSetButton);
***************
*** 973,977 ****
{
// Display level name
! if (options::WizardMode) {
snprintf (txt, sizeof(txt), "#%d: %s (%s)",
iselected+1, li->name.c_str(), li->filename.c_str());
--- 990,994 ----
{
// Display level name
! if (enigma::WizardMode) {
snprintf (txt, sizeof(txt), "#%d: %s (%s)",
iselected+1, li->name.c_str(), li->filename.c_str());
***************
*** 987,994 ****
}
else {
! int par_time, best_user_time;
! string par_name;
! get_best_times(li, options::GetLevelStatus (lp->get_name(),
li->filename),
! par_time, best_user_time, &par_name);
string your_time;
--- 1004,1010 ----
}
else {
! int par_time = lp->get_par_time (iselected,
GetDifficulty());
! int best_user_time = lp->get_best_user_time (iselected);
! string par_name = lp->get_par_holder (iselected,
GetDifficulty());
string your_time;
***************
*** 1041,1045 ****
void LevelMenu::draw_background(px::GC &gc) {
video::SetCaption("Enigma - Level Menu");
! sound::PlayMusic( MenuMusicFile.c_str());
blit(gc, 0,0, enigma::GetImage("menu_bg"));
--- 1057,1061 ----
void LevelMenu::draw_background(px::GC &gc) {
video::SetCaption("Enigma - Level Menu");
! sound::PlayMusic (options::GetString("MenuMusicFile"));
blit(gc, 0,0, enigma::GetImage("menu_bg"));
***************
*** 1075,1081 ****
! //----------------------------------------------------------------------
! // Main menu
! //----------------------------------------------------------------------
MainMenu::MainMenu()
--- 1091,1095 ----
! /* -------------------- Main menu -------------------- */
MainMenu::MainMenu()
***************
*** 1083,1088 ****
BuildVList b(this, Rect((640-150)/2,150,150,40), 5);
m_startgame = b.add(new TextButton("Start Game", this));
! // leveled = b.add(new TextButton("Editor", this));
! manual = b.add(new TextButton("Manual", this));
options = b.add(new TextButton("Options", this));
credits = b.add(new TextButton("Credits", this));
--- 1097,1102 ----
BuildVList b(this, Rect((640-150)/2,150,150,40), 5);
m_startgame = b.add(new TextButton("Start Game", this));
! leveled = b.add(new TextButton("Editor", this));
! // manual = b.add(new TextButton("Manual", this));
options = b.add(new TextButton("Options", this));
credits = b.add(new TextButton("Credits", this));
***************
*** 1090,1098 ****
}
! void
! MainMenu::draw_background(px::GC &gc)
! {
! video::SetCaption("Enigma - Main Menu");
! sound::PlayMusic( MenuMusicFile.c_str());
blit(gc, 0,0, enigma::GetImage("menu_bg"));
--- 1104,1110 ----
}
! void MainMenu::draw_background(px::GC &gc) {
! video::SetCaption ("Enigma - Main Menu");
! sound::PlayMusic (options::GetString("MenuMusicFile"));
blit(gc, 0,0, enigma::GetImage("menu_bg"));
***************
*** 1106,1116 ****
}
! void
! MainMenu::on_action(Widget *w)
! {
if (w == m_startgame) {
! LevelMenu m(enigma::LevelPacks[0], options::LevelMenuPosition);
m.manage(video::GetScreen());
! options::LevelMenuPosition = m.get_position();
invalidate_all();
}
--- 1118,1126 ----
}
! void MainMenu::on_action(Widget *w) {
if (w == m_startgame) {
! LevelMenu m(enigma::LevelPacks[0],
options::GetInt("LevelMenuPosition"));
m.manage(video::GetScreen());
! options::SetOption("LevelMenuPosition", m.get_position());
invalidate_all();
}
***************
*** 1130,1136 ****
}
! void
! MainMenu::show_text( const char *text[])
! {
Screen *scr = video::GetScreen ();
GC gc (scr->get_surface());
--- 1140,1144 ----
}
! void MainMenu::show_text( const char *text[]) {
Screen *scr = video::GetScreen ();
GC gc (scr->get_surface());
***************
*** 1250,1256 ****
}
! //----------------------------------------------------------------------
! // Functions
! //----------------------------------------------------------------------
void enigma::ShowMainMenu() {
--- 1258,1263 ----
}
!
! /* -------------------- Functions -------------------- */
void enigma::ShowMainMenu() {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Enigma-cvs] enigma/src menus.cc,1.75,1.76,
Daniel Heck <address@hidden> <=