Internal changes to the widget set (still some bugs, but none are visible in our screens), and layout and color changes to the race options menu.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1881 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
cosmosninja 2008-05-13 02:53:22 +00:00
parent 6c1553f7d2
commit 47c4602200
18 changed files with 998 additions and 270 deletions

View File

@ -39,7 +39,7 @@ enum WidgetTokens
ConfigControls::ConfigControls()
{
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTitleWgt( WTOK_TITLE, 60, 7, _("Edit controls for who?"));
widget_manager->addTextButtonWgt( WTOK_PLYR1 , 60, 7, _("Player 1"));

View File

@ -51,7 +51,7 @@ ConfigDisplay::ConfigDisplay()
m_curr_width = m_sizes[m_curr_res].first;
m_curr_height = m_sizes[m_curr_res].second;
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTitleWgt( WTOK_TITLE, 60, 7, _("Display Settings"));
if( isBlacklisted( m_curr_width, m_curr_height ))

View File

@ -36,7 +36,7 @@ enum WidgetTokens
ConfigSound::ConfigSound()
{
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTitleWgt(WTOK_TITLE, 50, 7, _("Sound Settings"));
widget_manager->setInitialActivationState(true);

View File

@ -46,7 +46,7 @@ DisplayResConfirm::DisplayResConfirm( const bool FROM_WINDOW_ ) :
{
m_counter = 5; // Number of seconds in which to confirm
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTitleWgt( WTOK_TITLE, 70, 7,
_("Confirm Resolution Within 5 Seconds"));

View File

@ -32,7 +32,7 @@ enum WidgetTokens
FeatureUnlocked::FeatureUnlocked()
{
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTitleWgt( WTOK_TITLE, 60, 10,
_("New Feature Unlocked"));

View File

@ -41,7 +41,7 @@ enum WidgetTokens
GameMode::GameMode()
{
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTitleWgt(WTOK_TITLE, 60, 7, _("Choose a Race Mode"));
if(unlock_manager->isLocked("grandprix"))

View File

@ -46,7 +46,7 @@ enum WidgetTokens
GrandPrixSelect::GrandPrixSelect() : m_curr_track_img(0), m_clock(0.0f)
{
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTitleWgt(WTOK_TITLE, 60, 7, _("Choose a Grand Prix") );
// Findout which grand prixs are available and load them

View File

@ -117,7 +117,7 @@ get stuck or fall too far, use the rescue button to get back on track."));
_("Check the current key bindings for the first player"));
widget_manager->breakLine();
widget_manager->insertColumn();
widget_manager->switchOrder();
/*The keybindings are placed with loops because it allows to change the
* number of kart actions without changing this screen. */
for(int i = WTOK_FIRST_KEYNAME; i <= WTOK_LAST_KEYNAME; ++i)
@ -128,7 +128,7 @@ get stuck or fall too far, use the rescue button to get back on track."));
}
widget_manager->breakLine();
widget_manager->insertColumn();
widget_manager->switchOrder();
for(int i = WTOK_FIRST_KEYBINDING; i <= WTOK_LAST_KEYBINDING; ++i)
{
widget_manager->addTextWgt( i, 20, 4,

View File

@ -43,7 +43,7 @@ enum WidgetTokens
HelpPageThree::HelpPageThree()
{
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTitleWgt( WTOK_TITLE, 100, 8, _("Game modes"));
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 100, 2 );

View File

@ -41,7 +41,7 @@ enum WidgetTokens
MainMenu::MainMenu()
{
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTextButtonWgt( WTOK_SINGLE, 25, 7, _("Single Player") );
widget_manager->addTextButtonWgt( WTOK_MULTI, 25, 7, _("Multiplayer") );

View File

@ -34,7 +34,7 @@ enum WidgetTokens
NumPlayers::NumPlayers()
{
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTextButtonWgt( WTOK_PLAYER_2, 35, 7, _("Two Players") );
widget_manager->addTextButtonWgt( WTOK_PLAYER_3, 35, 7, _("Three Players") );
widget_manager->addTextButtonWgt( WTOK_PLAYER_4, 35, 7, _("Four Players") );

View File

@ -36,7 +36,7 @@ enum WidgetTokens
Options::Options()
{
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTitleWgt( WTOK_TITLE, 45, 7, _("Options") );
widget_manager->addTextButtonWgt( WTOK_CONTROLS, 45, 7, _("Player Config") );

View File

@ -83,7 +83,7 @@ PlayerControls::PlayerControls(int whichPlayer):
widget_manager->addTextButtonWgt( WTOK_PLYR_NAME1, 30, 7, m_name );
widget_manager->breakLine();
widget_manager->insertColumn();
widget_manager->switchOrder();
for(int i = KA_FIRST; i <= KA_LAST; i++)
{
// Note: even though that all strings in sKartAction2Strings above
@ -97,7 +97,7 @@ PlayerControls::PlayerControls(int whichPlayer):
KartAction control;
widget_manager->insertColumn();
widget_manager->switchOrder();
for(int i = KA_FIRST; i <= KA_LAST; i++)
{
control = (KartAction)i;

View File

@ -42,7 +42,7 @@ enum WidgetTokens
RaceMenu::RaceMenu()
{
widget_manager->insertColumn();
widget_manager->switchOrder();
widget_manager->addTitleWgt( WTOK_PAUSE, 50, 7, _("Paused") );

View File

@ -52,37 +52,34 @@ enum WidgetTokens
};
RaceOptions::RaceOptions() :
m_difficulty(race_manager->getDifficulty()),
m_num_karts(race_manager->getNumKarts()),
m_difficulty(race_manager->getDifficulty()),
m_num_karts(race_manager->getNumKarts()),
m_num_laps(race_manager->getNumLaps())
{
widget_manager->addTextWgt( WTOK_TITLE, 60, 7, _("Choose the race options") );
widget_manager->breakLine();
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 1);
widget_manager->breakLine();
// Difficulty
// ==========
widget_manager->insertColumn();
widget_manager->addTextWgt( WTOK_DIFFICULTY_TITLE, 32, 7, _("Difficulty") );
widget_manager->addTextButtonWgt( WTOK_DIFFICULTY_UP, 20, 12, _("More") );
widget_manager->switchOrder();
widget_manager->addTextWgt( WTOK_DIFFICULTY_TITLE, 38, 7, _("Difficulty") );
widget_manager->switchOrder();
widget_manager->addTextButtonWgt( WTOK_DIFFICULTY_DOWN, 3, 7, _("<") );
widget_manager->addTextWgt( WTOK_DIFFICULTY, 32, 7, getDifficultyString(m_difficulty));
widget_manager->setWgtBorderPercentage( WTOK_DIFFICULTY, 10 );
widget_manager->showWgtBorder( WTOK_DIFFICULTY );
widget_manager->hideWgtRect( WTOK_DIFFICULTY );
widget_manager->addTextButtonWgt( WTOK_DIFFICULTY_DOWN, 20, 12, _("Less") );
widget_manager->addTextButtonWgt( WTOK_DIFFICULTY_UP, 3, 7, ">" );
widget_manager->breakLine();
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 1);
widget_manager->breakLine();
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 2, 1);
// Number of karts
// ===============
widget_manager->insertColumn();
widget_manager->addTextWgt( WTOK_KARTS_TITLE, 32, 7, _("Number of karts") );
widget_manager->addTextButtonWgt( WTOK_KARTS_UP, 20, 12, _("More") );
widget_manager->switchOrder();
widget_manager->addTextWgt( WTOK_KARTS_TITLE, 38, 7, _("Number of karts") );
widget_manager->switchOrder();
widget_manager->addTextButtonWgt( WTOK_KARTS_DOWN, 3, 7, "<" );
char string_num_karts[MAX_MESSAGE_LENGTH];
snprintf(string_num_karts, MAX_MESSAGE_LENGTH, "%d", m_num_karts);
@ -91,19 +88,24 @@ RaceOptions::RaceOptions() :
widget_manager->showWgtBorder( WTOK_KARTS );
widget_manager->hideWgtRect( WTOK_KARTS );
widget_manager->addTextButtonWgt( WTOK_KARTS_DOWN, 20, 12, _("Less") );
widget_manager->addTextButtonWgt( WTOK_KARTS_UP, 3, 7, ">" );
widget_manager->breakLine();
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 1);
widget_manager->breakLine();
widget_manager->breakLine();
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 2, 1);
widget_manager->breakLine();
// Number of laps
// ==============
if( race_manager->getRaceMode() != RaceManager::RM_GRAND_PRIX &&
race_manager->getRaceMode() != RaceManager::RM_FOLLOW_LEADER )
{
widget_manager->insertColumn();
widget_manager->addTextWgt( WTOK_LAPS_TITLE, 32, 7, _("Number of laps") );
widget_manager->addTextButtonWgt( WTOK_LAPS_UP, 20, 12, _("More") );
widget_manager->switchOrder();
widget_manager->addTextWgt( WTOK_LAPS_TITLE, 38, 7, _("Number of laps") );
widget_manager->switchOrder();
widget_manager->addTextButtonWgt( WTOK_LAPS_DOWN, 3, 7, "<" );
char string_num_laps[MAX_MESSAGE_LENGTH];
snprintf(string_num_laps, MAX_MESSAGE_LENGTH, "%d", m_num_laps);
@ -112,17 +114,22 @@ RaceOptions::RaceOptions() :
widget_manager->showWgtBorder( WTOK_LAPS );
widget_manager->hideWgtRect( WTOK_LAPS );
widget_manager->addTextButtonWgt( WTOK_LAPS_DOWN, 20, 12, _("Less") );
widget_manager->addTextButtonWgt( WTOK_LAPS_UP, 3, 7, ">" );
widget_manager->breakLine();
widget_manager->breakLine();
}
widget_manager->breakLine();
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 1);
widget_manager->breakLine();
//Lower buttons
//=============
widget_manager->switchOrder();
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 10);
widget_manager->addTextButtonWgt( WTOK_START, 60, 7, _("Start race") );
widget_manager->breakLine();
widget_manager->setWgtColor( WTOK_START, WGT_TRANS_RED );
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 1, 10);
widget_manager->addTextButtonWgt( WTOK_QUIT, 60, 7, _("Press <ESC> to go back") );
@ -278,4 +285,4 @@ const char *RaceOptions::getDifficultyString(int difficulty) const
default: return _("Novice");
} // switch
} // getDifficultyString
} // getDifficultyString

View File

@ -55,7 +55,7 @@ RaceResultsGUI::RaceResultsGUI()
widget_manager->addTextWgt( WTOK_HIGHSCORES, 50, 7, _("Highscores") );
widget_manager->breakLine();
widget_manager->insertColumn();
widget_manager->switchOrder();
const unsigned int MAX_STR_LEN = 60;
const unsigned int NUM_KARTS = race_manager->getNumKarts();
@ -102,7 +102,7 @@ RaceResultsGUI::RaceResultsGUI()
delete[] order;
widget_manager->breakLine();
widget_manager->insertColumn();
widget_manager->switchOrder();
const Highscores *hs = world->getHighscores();
int num_scores = hs->getNumberEntries();

File diff suppressed because it is too large Load Diff

View File

@ -23,20 +23,16 @@
#include <vector>
/* Here are some big-picture instructions about how to use this widget
* manager: the extern widget_manager is a global interface to the class. Call
* addWgt() to specify the widgets you want, and for each widget specify the
* details of it with the 'switch features', that can be changed between
* show/hide, the initial setting for all of them is to be hidden. You will
* usually have to call it's set*() function, then the show_*() functions.
* After you have defined all the widgets in the screen, call layout(), that
* will do the actual work at creating the widgets. Call the activated
* functions during the time the widgets are alive, and make sure that
* update() is called each frame.
/* Big-picture instructions: the extern widget_manager is a global interface
* to the class. Call add*Wgt() to insert new widgets, and change details
* using the 'switch features'. By default no feature besides the one for
* each widget type are enabled.
*
* You can use setInitial*State() to avoid setting the state of the same
* switch features with same values over and over; the default states are
* reset when you call reset() or you can use resetDefaultStates().
* After you defined the entire screen, call layout(), that creates and
* places the widgets. Call the activated functions during the time the
* widgets are alive, and make sure that update() is called each frame.
*
* To remove the widgets, you have to call reset().
*/
class WidgetManager
@ -69,13 +65,15 @@ class WidgetManager
{
ET_WGT,
ET_BREAK,
ET_COLUMN
ET_SWITCH //Switch orientation
};
/* I decided to waste one integer per break/column with the pos
/* I decided to waste one integer per break/switch with the pos
* variable inside the WidgetElement struct, since otherwise we
* would need 2 vectors for breaks and columns, which would use more
* memory, be slower and more complex than this. -Coz
* memory, be slower and more complex than this; another approach
* is to use classes for each ElementType, but this most likely will also
* waste more resources. -Coz
*/
struct WidgetElement
{
@ -131,16 +129,28 @@ class WidgetManager
int m_default_show_track;
int m_default_track_num;
bool isColumnBreak( const int BREAK_POST ) const;
int findId(const int TOKEN) const;
int calcWidth() const;
int calcHeight() const;
int calcLineWidth(const int START_ELEM) const;
int calcLineHeight(const int START_ELEM) const;
int calcColumnWidth(const int START_ELEM) const;
int calcColumnHeight(const int START_ELEM) const;
int calcLineWidth( const int POS );
int calcLineHeight( const int POS );
int calcColumnWidth( const int POS );
int calcColumnHeight( const int POS );
//These get* functions return the same thing as the above functions, but
//they modify pos and set it to the position of the last element
int getLineWidth( int& pos);
int getLineHeight( int& pos );
int getColumnWidth( int& pos );
int getColumnHeight( int& pos );
int calcLineX( const int POS );
int calcColumnX( const int POS );
int calcWidth();
int calcHeight();
bool layoutLine( int& x, int& y, int& pos );
bool layoutColumn( int& x, int& y, int& pos );
int findLeftWidget(const int START_WGT) const;
int findRightWidget(const int START_WGT) const;
@ -167,15 +177,10 @@ public:
//is the whole screen.
const int MIN_HEIGHT
);
bool insertColumn(); //This function changes the orientation from left to
//right and top to bottom of the widgets at line
//breaks, and switches it, making it from top to
//bottom, and left to right at a line break,
//until the next line break or reset() call. It can
//only be used right at the beginning
//of a line (that is, before any widgets have been
//created, or just after a line break).
bool breakLine();
bool switchOrder(); //This changes the orientation from horizontal to
//vertical. It's reverted at line breaks;
void reset();