Fixed widget scrolling and removed font aligment option.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1328 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
7e68fd5ddf
commit
6bd0861ad4
@ -43,7 +43,7 @@ ConfigControls::ConfigControls()
|
|||||||
const bool SHOW_RECT = true;
|
const bool SHOW_RECT = true;
|
||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED );
|
||||||
|
|
||||||
widget_manager->insert_column();
|
widget_manager->insert_column();
|
||||||
widget_manager->add_wgt( WTOK_TITLE, 60, 7 );
|
widget_manager->add_wgt( WTOK_TITLE, 60, 7 );
|
||||||
|
@ -57,7 +57,7 @@ ConfigDisplay::ConfigDisplay()
|
|||||||
const bool SHOW_RECT = true;
|
const bool SHOW_RECT = true;
|
||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED );
|
||||||
|
|
||||||
widget_manager->insert_column();
|
widget_manager->insert_column();
|
||||||
widget_manager->add_wgt( WTOK_TITLE, 40, 7);
|
widget_manager->add_wgt( WTOK_TITLE, 40, 7);
|
||||||
|
@ -39,7 +39,7 @@ ConfigSound::ConfigSound()
|
|||||||
const bool SHOW_RECT = true;
|
const bool SHOW_RECT = true;
|
||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED );
|
||||||
|
|
||||||
widget_manager->insert_column();
|
widget_manager->insert_column();
|
||||||
widget_manager->add_wgt(WTOK_TITLE, 40, 7);
|
widget_manager->add_wgt(WTOK_TITLE, 40, 7);
|
||||||
|
@ -69,13 +69,14 @@ CreditsMenu::CreditsMenu()
|
|||||||
|
|
||||||
widget_manager->set_initial_activation_state( true );
|
widget_manager->set_initial_activation_state( true );
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", TEXT_SIZE, Font::ALIGN_CENTER, Font::ALIGN_CENTER);
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", TEXT_SIZE );
|
||||||
|
|
||||||
widget_manager->add_wgt( WTOK_CREDITS, 100, 93);
|
widget_manager->add_wgt( WTOK_CREDITS, 100, 93);
|
||||||
widget_manager->set_wgt_text( WTOK_CREDITS, credits_text );
|
widget_manager->set_wgt_text( WTOK_CREDITS, credits_text );
|
||||||
widget_manager->set_wgt_text_x_alignment( WTOK_CREDITS, Font::ALIGN_LEFT );
|
|
||||||
//FIXME: maybe I should make scroll names more consistent
|
//FIXME: maybe I should make scroll names more consistent
|
||||||
widget_manager->enable_wgt_scroll( WTOK_CREDITS );
|
widget_manager->enable_wgt_scroll( WTOK_CREDITS );
|
||||||
|
widget_manager->set_wgt_y_scroll_pos( WTOK_CREDITS, WGT_SCROLL_START_BOTTOM );
|
||||||
|
widget_manager->set_wgt_y_scroll_speed( WTOK_CREDITS, -0.25f );
|
||||||
widget_manager->break_line();
|
widget_manager->break_line();
|
||||||
|
|
||||||
widget_manager->add_wgt( WTOK_QUIT, 40, 7);
|
widget_manager->add_wgt( WTOK_QUIT, 40, 7);
|
||||||
|
@ -38,7 +38,7 @@ Difficulty::Difficulty()
|
|||||||
const bool SHOW_RECT = true;
|
const bool SHOW_RECT = true;
|
||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED );
|
||||||
|
|
||||||
widget_manager->insert_column();
|
widget_manager->insert_column();
|
||||||
widget_manager->add_wgt(WTOK_TITLE, 60, 7);
|
widget_manager->add_wgt(WTOK_TITLE, 60, 7);
|
||||||
|
@ -67,8 +67,7 @@ Font::~Font()
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void Font::Print(const char *text, int size,
|
void Font::Print(const char *text, int size,
|
||||||
FontAlignType fontalign_x, int x,
|
int x, int y,
|
||||||
FontAlignType fontalign_y, int y,
|
|
||||||
int red, int green, int blue,
|
int red, int green, int blue,
|
||||||
float scale_x, float scale_y,
|
float scale_x, float scale_y,
|
||||||
int left, int right, int top, int bottom, bool doShadow)
|
int left, int right, int top, int bottom, bool doShadow)
|
||||||
@ -83,33 +82,25 @@ void Font::Print(const char *text, int size,
|
|||||||
m_fnt->getBBox(text, sz, 0, &l, &r, &b, &t);
|
m_fnt->getBBox(text, sz, 0, &l, &r, &b, &t);
|
||||||
const int W = (int)((r-l+0.99));
|
const int W = (int)((r-l+0.99));
|
||||||
const int H = (int)((t-b+0.99));
|
const int H = (int)((t-b+0.99));
|
||||||
if(fontalign_x == ALIGN_CENTER)
|
|
||||||
|
if(x==CENTER_OF_SCREEN)
|
||||||
{
|
{
|
||||||
if(x==CENTER_OF_SCREEN)
|
if(left ==-1) left = 0;
|
||||||
{
|
if(right==-1) right = user_config->m_width-1;
|
||||||
if(left ==-1) left = 0;
|
int width = right-left+1;
|
||||||
if(right==-1) right = user_config->m_width-1;
|
x = (width - W)/2 + left;
|
||||||
int width = right-left+1;
|
|
||||||
x = (width - W)/2 + left;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
x -= W/2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(fontalign_y == ALIGN_CENTER)
|
|
||||||
|
if(y==CENTER_OF_SCREEN)
|
||||||
{
|
{
|
||||||
if(y==CENTER_OF_SCREEN)
|
if(top == -1) top = user_config->m_height-1;
|
||||||
{
|
if(bottom == -1) bottom = 0;
|
||||||
if(top == -1) top = user_config->m_height-1;
|
int height = top-bottom+1;
|
||||||
if(bottom == -1) bottom = 0;
|
y = (height - H)/2 + bottom;
|
||||||
int height = top-bottom+1;
|
}
|
||||||
y = (height - H)/2 + bottom;
|
else
|
||||||
}
|
{
|
||||||
else
|
y -= H/2;
|
||||||
{
|
|
||||||
y-=H/2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_text_out->begin();
|
m_text_out->begin();
|
||||||
|
@ -31,8 +31,6 @@ private:
|
|||||||
fntRenderer *m_text_out;
|
fntRenderer *m_text_out;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Align right and top are not supported yet
|
|
||||||
enum FontAlignType {ALIGN_LEFT, ALIGN_CENTER, ALIGN_BOTTOM};
|
|
||||||
const static int CENTER_OF_SCREEN=-1;
|
const static int CENTER_OF_SCREEN=-1;
|
||||||
enum FontSize {SMALL=18, MEDIUM=24, LARGE=30 };
|
enum FontSize {SMALL=18, MEDIUM=24, LARGE=30 };
|
||||||
Font(const char* fontname);
|
Font(const char* fontname);
|
||||||
@ -47,55 +45,56 @@ public:
|
|||||||
// The actual main function which does everything
|
// The actual main function which does everything
|
||||||
// ----------------------------------------------
|
// ----------------------------------------------
|
||||||
void Print( const char *text, int size,
|
void Print( const char *text, int size,
|
||||||
FontAlignType fontalign_x, int x,
|
int x, int y,
|
||||||
FontAlignType fontalign_y, int y,
|
|
||||||
int red=255, int green=255, int blue=255,
|
int red=255, int green=255, int blue=255,
|
||||||
float scale_x=1.0f, float scale_y=1.0f,
|
float scale_x=1.0f, float scale_y=1.0f,
|
||||||
int left=-1, int right=-1, int top=-1, int bottom=-1,
|
int left=-1, int right=-1, int top=-1, int bottom=-1,
|
||||||
bool doShadow=false);
|
bool doShadow=false);
|
||||||
void Print( std::string const &text, int size,
|
void Print( std::string const &text, int size,
|
||||||
FontAlignType fontalign_x, int x,
|
int x, int y,
|
||||||
FontAlignType fontalign_y, int y,
|
|
||||||
int red=255, int green=255, int blue=255,
|
int red=255, int green=255, int blue=255,
|
||||||
float scale_x=1.0f, float scale_y=1.0f,
|
float scale_x=1.0f, float scale_y=1.0f,
|
||||||
int left=-1, int right=-1, int top=-1, int bottom=-1,
|
int left=-1, int right=-1, int top=-1, int bottom=-1,
|
||||||
bool doShadow=false)
|
bool doShadow=false)
|
||||||
{
|
{
|
||||||
Print(text.c_str(), size, fontalign_x, x, fontalign_y, y,
|
Print(text.c_str(), size, x, y,
|
||||||
red, green, blue, scale_x, scale_y, left, right, top, bottom,
|
red, green, blue, scale_x, scale_y, left, right, top, bottom,
|
||||||
doShadow);
|
doShadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
// Convenience functions to reduce the number of parameters
|
// Convenience functions to reduce the number of parameters
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
void Print( const std::string &text, int size, int x, int y,
|
void Print( const std::string &text, int size, int x, int y,
|
||||||
int red=255, int green=255, int blue=255,
|
int red=255, int green=255, int blue=255,
|
||||||
int left=-1, int right=-1, int top=-1, int bottom=-1)
|
int left=-1, int right=-1, int top=-1, int bottom=-1)
|
||||||
{
|
{
|
||||||
Print(text, size, ALIGN_LEFT, x, ALIGN_BOTTOM, y,
|
Print(text, size, x, y,
|
||||||
red, green, blue, 1.0f, 1.0f,
|
red, green, blue, 1.0f, 1.0f,
|
||||||
left, right, top, bottom);
|
left, right, top, bottom);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void PrintShadow(const char *text, int size,
|
void PrintShadow(const char *text, int size,
|
||||||
FontAlignType fontalign_x, int x,
|
int x, int y,
|
||||||
FontAlignType fontalign_y, int y,
|
|
||||||
int red=255, int green=255, int blue=255,
|
int red=255, int green=255, int blue=255,
|
||||||
float scale_x=1.0f, float scale_y=1.0f,
|
float scale_x=1.0f, float scale_y=1.0f,
|
||||||
int left=-1, int right=-1, int top=-1, int bottom=-1)
|
int left=-1, int right=-1, int top=-1, int bottom=-1)
|
||||||
{
|
{
|
||||||
Print(text, size, fontalign_x, x, fontalign_y, y,
|
Print(text, size, x, y,
|
||||||
red, green, blue, scale_x, scale_y,
|
red, green, blue, scale_x, scale_y,
|
||||||
left, right, top, bottom, true);
|
left, right, top, bottom, true);
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
void PrintShadow(const char *text, int size, int x, int y,
|
void PrintShadow(const char *text, int size, int x, int y,
|
||||||
int red=255, int green=255, int blue=255,
|
int red=255, int green=255, int blue=255,
|
||||||
int left=-1, int right=-1, int top=-1, int bottom=-1)
|
int left=-1, int right=-1, int top=-1, int bottom=-1)
|
||||||
{
|
{
|
||||||
Print(text, size, ALIGN_LEFT, x, ALIGN_BOTTOM, y,
|
Print(text, size, x, y,
|
||||||
red, green, blue, 1.0f, 1.0f,
|
red, green, blue, 1.0f, 1.0f,
|
||||||
left, right, top, bottom, true);
|
left, right, top, bottom, true);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
int init_fonts();
|
int init_fonts();
|
||||||
|
@ -37,7 +37,7 @@ GameMode::GameMode()
|
|||||||
const bool SHOW_RECT = true;
|
const bool SHOW_RECT = true;
|
||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED );
|
||||||
|
|
||||||
widget_manager->insert_column();
|
widget_manager->insert_column();
|
||||||
widget_manager->add_wgt(WTOK_TITLE, 50, 7);
|
widget_manager->add_wgt(WTOK_TITLE, 50, 7);
|
||||||
|
@ -47,7 +47,7 @@ GrandPrixSelect::GrandPrixSelect()
|
|||||||
const bool SHOW_RECT = true;
|
const bool SHOW_RECT = true;
|
||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED );
|
||||||
|
|
||||||
widget_manager->insert_column();
|
widget_manager->insert_column();
|
||||||
widget_manager->add_wgt(WTOK_TITLE, 40, 7);
|
widget_manager->add_wgt(WTOK_TITLE, 40, 7);
|
||||||
|
@ -155,7 +155,7 @@ void HelpMenu::switch_to_first_screen()
|
|||||||
const WidgetFontSize TEXT_SIZE = WGT_FNT_SML;
|
const WidgetFontSize TEXT_SIZE = WGT_FNT_SML;
|
||||||
|
|
||||||
widget_manager->set_initial_rect_state( SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK );
|
widget_manager->set_initial_rect_state( SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK );
|
||||||
widget_manager->set_initial_text_state( SHOW_TEXT, "", TEXT_SIZE, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state( SHOW_TEXT, "", TEXT_SIZE );
|
||||||
|
|
||||||
/*Help header*/
|
/*Help header*/
|
||||||
widget_manager->add_wgt(WTOK_MSG1, 50, 7);
|
widget_manager->add_wgt(WTOK_MSG1, 50, 7);
|
||||||
@ -262,7 +262,7 @@ void HelpMenu::switch_to_second_screen()
|
|||||||
const bool SHOW_RECT = true;
|
const bool SHOW_RECT = true;
|
||||||
const WidgetFontSize TEXT_SIZE = WGT_FNT_SML;
|
const WidgetFontSize TEXT_SIZE = WGT_FNT_SML;
|
||||||
widget_manager->set_initial_rect_state( SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK );
|
widget_manager->set_initial_rect_state( SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK );
|
||||||
widget_manager->set_initial_text_state( false, "", TEXT_SIZE, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state( false, "", TEXT_SIZE );
|
||||||
|
|
||||||
widget_manager->add_wgt(WTOK_MSG6, 100, 8);
|
widget_manager->add_wgt(WTOK_MSG6, 100, 8);
|
||||||
widget_manager->set_wgt_text(WTOK_MSG6,
|
widget_manager->set_wgt_text(WTOK_MSG6,
|
||||||
|
@ -41,7 +41,7 @@ MainMenu::MainMenu()
|
|||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_activation_state(true);
|
widget_manager->set_initial_activation_state(true);
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED );
|
||||||
|
|
||||||
widget_manager->insert_column();
|
widget_manager->insert_column();
|
||||||
widget_manager->add_wgt(WTOK_SINGLE, 25, 7);
|
widget_manager->add_wgt(WTOK_SINGLE, 25, 7);
|
||||||
|
@ -72,7 +72,7 @@ PlayerControls::PlayerControls(int whichPlayer):
|
|||||||
const bool SHOW_RECT = true;
|
const bool SHOW_RECT = true;
|
||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED );
|
||||||
|
|
||||||
widget_manager->add_wgt( WTOK_TITLE, 60, 7);
|
widget_manager->add_wgt( WTOK_TITLE, 60, 7);
|
||||||
sprintf(m_heading, _("Choose your controls, %s"),
|
sprintf(m_heading, _("Choose your controls, %s"),
|
||||||
|
@ -800,8 +800,7 @@ void RaceGUI::drawAllMessages(Kart* player_kart, int offset_x, int offset_y,
|
|||||||
if( msg.m_kart && msg.m_kart!=player_kart) continue;
|
if( msg.m_kart && msg.m_kart!=player_kart) continue;
|
||||||
|
|
||||||
font_race->Print( msg.m_message.c_str(), msg.m_font_size,
|
font_race->Print( msg.m_message.c_str(), msg.m_font_size,
|
||||||
Font::ALIGN_CENTER, Font::CENTER_OF_SCREEN,
|
Font::CENTER_OF_SCREEN, y,
|
||||||
Font::ALIGN_BOTTOM, y,
|
|
||||||
msg.m_red, msg.m_green, msg.m_blue,
|
msg.m_red, msg.m_green, msg.m_blue,
|
||||||
ratio_x, ratio_y,
|
ratio_x, ratio_y,
|
||||||
offset_x, offset_x+(int)(user_config->m_width*ratio_x));
|
offset_x, offset_x+(int)(user_config->m_width*ratio_x));
|
||||||
@ -849,18 +848,18 @@ void RaceGUI::drawStatusText (const RaceSetup& raceSetup, const float dt)
|
|||||||
switch (world->m_ready_set_go)
|
switch (world->m_ready_set_go)
|
||||||
{
|
{
|
||||||
case 2: font_race->PrintShadow(_("Ready!"), 90,
|
case 2: font_race->PrintShadow(_("Ready!"), 90,
|
||||||
Font::ALIGN_CENTER, Font::CENTER_OF_SCREEN,
|
Font::CENTER_OF_SCREEN,
|
||||||
Font::ALIGN_CENTER, Font::CENTER_OF_SCREEN,
|
Font::CENTER_OF_SCREEN,
|
||||||
230, 170, 160);
|
230, 170, 160);
|
||||||
break;
|
break;
|
||||||
case 1: font_race->PrintShadow(_("Set!"), 90,
|
case 1: font_race->PrintShadow(_("Set!"), 90,
|
||||||
Font::ALIGN_CENTER, Font::CENTER_OF_SCREEN,
|
Font::CENTER_OF_SCREEN,
|
||||||
Font::ALIGN_CENTER, Font::CENTER_OF_SCREEN,
|
Font::CENTER_OF_SCREEN,
|
||||||
230, 230, 160);
|
230, 230, 160);
|
||||||
break;
|
break;
|
||||||
case 0: font_race->PrintShadow(_("Go!"), 90,
|
case 0: font_race->PrintShadow(_("Go!"), 90,
|
||||||
Font::ALIGN_CENTER, Font::CENTER_OF_SCREEN,
|
Font::CENTER_OF_SCREEN,
|
||||||
Font::ALIGN_CENTER, Font::CENTER_OF_SCREEN,
|
Font::CENTER_OF_SCREEN,
|
||||||
100, 210, 100);
|
100, 210, 100);
|
||||||
break;
|
break;
|
||||||
} // switch
|
} // switch
|
||||||
@ -878,8 +877,8 @@ void RaceGUI::drawStatusText (const RaceSetup& raceSetup, const float dt)
|
|||||||
if(world->getPlayerKart(i)->earlyStartPenalty())
|
if(world->getPlayerKart(i)->earlyStartPenalty())
|
||||||
{
|
{
|
||||||
font_race->PrintShadow(_("Penalty time!!"), 80,
|
font_race->PrintShadow(_("Penalty time!!"), 80,
|
||||||
Font::ALIGN_CENTER, Font::CENTER_OF_SCREEN,
|
Font::CENTER_OF_SCREEN, 200,
|
||||||
Font::ALIGN_BOTTOM, 200, 200, 10, 10);
|
200, 10, 10);
|
||||||
} // if penalty
|
} // if penalty
|
||||||
} // for i < getNumPlayers
|
} // for i < getNumPlayers
|
||||||
} // if not RACE_PHASE
|
} // if not RACE_PHASE
|
||||||
|
@ -44,7 +44,7 @@ RaceMenu::RaceMenu()
|
|||||||
const bool SHOW_RECT = true;
|
const bool SHOW_RECT = true;
|
||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED );
|
||||||
|
|
||||||
widget_manager->add_wgt(WTOK_PAUSE, 30, 7);
|
widget_manager->add_wgt(WTOK_PAUSE, 30, 7);
|
||||||
widget_manager->set_wgt_text(WTOK_PAUSE, _("Paused"));
|
widget_manager->set_wgt_text(WTOK_PAUSE, _("Paused"));
|
||||||
|
@ -45,7 +45,7 @@ RaceResultsGUI::RaceResultsGUI()
|
|||||||
const bool SHOW_RECT = true;
|
const bool SHOW_RECT = true;
|
||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_MED );
|
||||||
widget_manager->add_wgt(WTOK_TITLE, 60, 7);
|
widget_manager->add_wgt(WTOK_TITLE, 60, 7);
|
||||||
widget_manager->set_wgt_text(WTOK_TITLE, _("Result"));
|
widget_manager->set_wgt_text(WTOK_TITLE, _("Result"));
|
||||||
widget_manager->break_line();
|
widget_manager->break_line();
|
||||||
|
@ -68,7 +68,7 @@ TrackSel::TrackSel()
|
|||||||
const bool SHOW_TEXT = true;
|
const bool SHOW_TEXT = true;
|
||||||
widget_manager->set_initial_activation_state(true);
|
widget_manager->set_initial_activation_state(true);
|
||||||
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_SML, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(SHOW_TEXT, "", WGT_FNT_SML );
|
||||||
for (size_t i = 0; i != track_manager->getTrackCount(); i += 2)
|
for (size_t i = 0; i != track_manager->getTrackCount(); i += 2)
|
||||||
{
|
{
|
||||||
widget_manager->add_wgt( WTOK_TRACK0 + i, 40, 7);
|
widget_manager->add_wgt( WTOK_TRACK0 + i, 40, 7);
|
||||||
@ -81,7 +81,7 @@ TrackSel::TrackSel()
|
|||||||
//FIXME: Right now, the image and the author's name is not controlled by the widget manager.
|
//FIXME: Right now, the image and the author's name is not controlled by the widget manager.
|
||||||
#if 0
|
#if 0
|
||||||
widget_manager->set_initial_rect_state(false, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
widget_manager->set_initial_rect_state(false, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||||
widget_manager->set_initial_text_state(false, "", WGT_FNT_MED, Font::ALIGN_CENTER, Font::ALIGN_CENTER );
|
widget_manager->set_initial_text_state(false, "", WGT_FNT_MED );
|
||||||
widget_manager->set_initial_activation_state(false);
|
widget_manager->set_initial_activation_state(false);
|
||||||
widget_manager->add_wgt( WidgetManager::WGT_NONE, 100, 5);
|
widget_manager->add_wgt( WidgetManager::WGT_NONE, 100, 5);
|
||||||
widget_manager->break_line();
|
widget_manager->break_line();
|
||||||
@ -174,8 +174,7 @@ void TrackSel::update(float dt)
|
|||||||
// glCallList(m_rect);
|
// glCallList(m_rect);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
font_gui->Print(TRACK->getDescription(), WGT_FNT_MED,
|
font_gui->Print(TRACK->getDescription(), WGT_FNT_MED,
|
||||||
Font::ALIGN_CENTER, -1,
|
Font::CENTER_OF_SCREEN, 10);
|
||||||
Font::ALIGN_BOTTOM, 10);
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
172
src/widget.cpp
172
src/widget.cpp
@ -28,6 +28,8 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
const int Widget::MAX_SCROLL = 1000000;
|
||||||
|
|
||||||
const float Widget::MAX_TEXT_SCALE = 1.2f;
|
const float Widget::MAX_TEXT_SCALE = 1.2f;
|
||||||
const float Widget::MIN_TEXT_SCALE = 1.0f;
|
const float Widget::MIN_TEXT_SCALE = 1.0f;
|
||||||
|
|
||||||
@ -73,8 +75,8 @@ Widget::Widget
|
|||||||
m_width(WIDTH_), m_height(HEIGHT_),
|
m_width(WIDTH_), m_height(HEIGHT_),
|
||||||
m_rect_list(0),
|
m_rect_list(0),
|
||||||
m_round_corners(WGT_AREA_ALL),
|
m_round_corners(WGT_AREA_ALL),
|
||||||
/*m_scroll_pos_x(0),*/ m_scroll_pos_y(0),
|
m_scroll_pos_x(0), m_scroll_pos_y(0),
|
||||||
/*m_scroll_speed_x(0),*/ m_scroll_speed_y(0),
|
m_scroll_speed_x(0), m_scroll_speed_y(0.0f),
|
||||||
m_text_scale(1.0f)
|
m_text_scale(1.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -101,8 +103,7 @@ void Widget::update(const float DELTA)
|
|||||||
if(m_text_scale < MIN_TEXT_SCALE) m_text_scale = MIN_TEXT_SCALE;
|
if(m_text_scale < MIN_TEXT_SCALE) m_text_scale = MIN_TEXT_SCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Handle on/off features*/
|
/*Start handling of on/off features*/
|
||||||
//Draw widget
|
|
||||||
if(m_enable_texture)
|
if(m_enable_texture)
|
||||||
{
|
{
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
@ -142,7 +143,8 @@ void Widget::update(const float DELTA)
|
|||||||
//text when there are multiple lines. Hopefully this work around will
|
//text when there are multiple lines. Hopefully this work around will
|
||||||
//be removed when we move away from plib; the scrolling and the other
|
//be removed when we move away from plib; the scrolling and the other
|
||||||
//text handling should be cleaned. Also, for some reason, different
|
//text handling should be cleaned. Also, for some reason, different
|
||||||
//positions are needed if the text is centered. Sorry for the mess.
|
//positions are needed if the text is centered, and on top of that,
|
||||||
|
//it's not 100% exact. Sorry for the mess.
|
||||||
size_t line_end = 0;
|
size_t line_end = 0;
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
|
|
||||||
@ -152,66 +154,114 @@ void Widget::update(const float DELTA)
|
|||||||
++lines;
|
++lines;
|
||||||
} while( line_end != std::string::npos );
|
} while( line_end != std::string::npos );
|
||||||
|
|
||||||
|
/* Handle preset scrolling positions */
|
||||||
|
// In the Y-axis, a scroll position of 0 leaves the text centered, and
|
||||||
|
// positive values lowers the text, and negatives (obviously) raise the
|
||||||
|
// text, in the X-axis, a position of 0 leaves the text aligned to the
|
||||||
|
// left; positive values move to the right and negative
|
||||||
|
// values to the left.
|
||||||
|
|
||||||
|
float left, right, bottom, top;
|
||||||
|
font_gui->getBBox(m_text.c_str(), m_text_size, false, &left, &right, &bottom, &top);
|
||||||
|
int text_width = (int)(right - left + 0.99);
|
||||||
|
|
||||||
|
const int Y_LIMIT = lines * m_text_size + m_height;
|
||||||
|
|
||||||
|
//A work around for yet another bug with multilines: we get the wrong
|
||||||
|
//width when using multilines.
|
||||||
|
if( text_width > m_width )
|
||||||
|
{
|
||||||
|
text_width = m_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Y-axis preset positions
|
||||||
|
if( m_scroll_pos_y == WGT_SCROLL_START_TOP )
|
||||||
|
{
|
||||||
|
m_scroll_pos_y = Y_LIMIT / 2 - m_height;
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_y == WGT_SCROLL_START_BOTTOM )
|
||||||
|
{
|
||||||
|
m_scroll_pos_y = Y_LIMIT / 2;
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_y == WGT_SCROLL_CENTER )
|
||||||
|
{
|
||||||
|
m_scroll_pos_y = 0;
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_y == WGT_SCROLL_END_TOP )
|
||||||
|
{
|
||||||
|
m_scroll_pos_y = -Y_LIMIT / 2;
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_y == WGT_SCROLL_END_BOTTOM )
|
||||||
|
{
|
||||||
|
m_scroll_pos_y = -Y_LIMIT / 2 + m_height;
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_y > MAX_SCROLL )
|
||||||
|
{
|
||||||
|
std::cerr << "WARNING: text position too high to scroll!.\n";
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_y < -MAX_SCROLL )
|
||||||
|
{
|
||||||
|
std::cerr << "WARNING: text position too low to scroll!.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//X-axis preset positions
|
||||||
|
if( m_scroll_pos_x == WGT_SCROLL_START_LEFT )
|
||||||
|
{
|
||||||
|
m_scroll_pos_x = 0;
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_x == WGT_SCROLL_START_RIGHT )
|
||||||
|
{
|
||||||
|
m_scroll_pos_x = m_width;
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_x == WGT_SCROLL_CENTER )
|
||||||
|
{
|
||||||
|
m_scroll_pos_x = (m_width - text_width) / 2;
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_x == WGT_SCROLL_END_LEFT )
|
||||||
|
{
|
||||||
|
m_scroll_pos_x = -text_width;
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_x == WGT_SCROLL_END_RIGHT )
|
||||||
|
{
|
||||||
|
m_scroll_pos_x = -text_width + m_width;
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_x > MAX_SCROLL )
|
||||||
|
{
|
||||||
|
std::cerr << "WARNING: text position is too much to the right to " <<
|
||||||
|
"scroll!.\n";
|
||||||
|
}
|
||||||
|
else if( m_scroll_pos_x < -MAX_SCROLL )
|
||||||
|
{
|
||||||
|
std::cerr << "WARNING: text position is too much to the left to " <<
|
||||||
|
"to scroll!.\n";
|
||||||
|
}
|
||||||
|
|
||||||
if(m_enable_scroll)
|
if(m_enable_scroll)
|
||||||
{
|
{
|
||||||
//TODO: constrain speed to sane values
|
//TODO: constrain speed to sane values
|
||||||
/*m_scroll_pos_x += m_scroll_speed_x;*/
|
m_scroll_pos_x += m_scroll_speed_x;
|
||||||
m_scroll_pos_y += m_scroll_speed_y;
|
m_scroll_pos_y += m_scroll_speed_y;
|
||||||
|
|
||||||
if( m_text_y_alignment == Font::ALIGN_CENTER )
|
//Y-axis wrapping
|
||||||
|
if(m_scroll_pos_y * 2 > Y_LIMIT)
|
||||||
{
|
{
|
||||||
const int LIMIT = lines * m_text_size + m_height;
|
m_scroll_pos_y = WGT_SCROLL_END_TOP;
|
||||||
if(m_scroll_pos_y * 2 > LIMIT)
|
|
||||||
{
|
|
||||||
m_scroll_pos_y = -LIMIT / 2;
|
|
||||||
}
|
|
||||||
else if(-m_scroll_pos_y * 2 > LIMIT)
|
|
||||||
{
|
|
||||||
m_scroll_pos_y = LIMIT / 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if( m_text_y_alignment == Font::ALIGN_BOTTOM )
|
else if(-m_scroll_pos_y * 2 > Y_LIMIT)
|
||||||
{
|
{
|
||||||
const int TEXT_HEIGHT = lines * m_text_size;
|
m_scroll_pos_y = WGT_SCROLL_START_BOTTOM;
|
||||||
if(m_scroll_pos_y > TEXT_HEIGHT / 2)
|
|
||||||
{
|
|
||||||
m_scroll_pos_y = -m_height - (TEXT_HEIGHT) / 2;
|
|
||||||
}
|
|
||||||
else if(m_scroll_pos_y < - m_height - TEXT_HEIGHT / 2)
|
|
||||||
{
|
|
||||||
m_scroll_pos_y = TEXT_HEIGHT / 2 + m_text_size;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//X-axis wrapping
|
||||||
float left, right;
|
if(m_scroll_pos_x > m_width )
|
||||||
font_gui->getBBox(m_text.c_str(), m_text_size, false, &left, &right, NULL, NULL);
|
{
|
||||||
const int TEXT_WIDTH = (int)(right - left) / m_text_size;
|
m_scroll_pos_x = WGT_SCROLL_END_LEFT;
|
||||||
|
}
|
||||||
|
else if(m_scroll_pos_x < -text_width )
|
||||||
|
{
|
||||||
|
m_scroll_pos_x = WGT_SCROLL_START_RIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
if( m_text_x_alignment == Font::ALIGN_CENTER )
|
|
||||||
{
|
|
||||||
const int LIMIT = TEXT_WIDTH + m_width;
|
|
||||||
if(m_scroll_pos_x * 2 > LIMIT)
|
|
||||||
{
|
|
||||||
m_scroll_pos_x = -LIMIT / 2;
|
|
||||||
}
|
|
||||||
else if(-m_scroll_pos_x * 2 > LIMIT)
|
|
||||||
{
|
|
||||||
m_scroll_pos_x = LIMIT / 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( m_text_x_alignment == Font::ALIGN_LEFT )
|
|
||||||
{
|
|
||||||
if(m_scroll_pos_x > TEXT_WIDTH / 2)
|
|
||||||
{
|
|
||||||
m_scroll_pos_x = -m_width - (TEXT_WIDTH) / 2;
|
|
||||||
}
|
|
||||||
else if(m_scroll_pos_x < - m_width - TEXT_WIDTH / 2)
|
|
||||||
{
|
|
||||||
m_scroll_pos_x = TEXT_WIDTH / 2 + m_text_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_enable_text)
|
if(m_enable_text)
|
||||||
@ -222,14 +272,10 @@ void Widget::update(const float DELTA)
|
|||||||
std::cerr << "(Did you set the text?)\n";
|
std::cerr << "(Did you set the text?)\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
int x_pos = m_x;// + m_scroll_pos_x;
|
int x_pos = m_x + (int)m_scroll_pos_x;
|
||||||
int y_pos = m_y - m_scroll_pos_y + ((lines - 1 )* m_text_size) / 2;
|
int y_pos = m_y - (int)m_scroll_pos_y + ((lines - 1 )* m_text_size) / 2;
|
||||||
|
|
||||||
if( m_text_x_alignment == Font::ALIGN_CENTER ) x_pos += m_width / 2;
|
y_pos += m_height / 2;
|
||||||
if( m_text_y_alignment == Font::ALIGN_CENTER )
|
|
||||||
{
|
|
||||||
y_pos += m_height / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t line_start = 0;
|
size_t line_start = 0;
|
||||||
bool draw;
|
bool draw;
|
||||||
@ -262,7 +308,7 @@ void Widget::update(const float DELTA)
|
|||||||
if( draw )
|
if( draw )
|
||||||
{
|
{
|
||||||
font_gui->Print(m_text.substr(line_start, line_end - line_start).c_str(), m_text_size,
|
font_gui->Print(m_text.substr(line_start, line_end - line_start).c_str(), m_text_size,
|
||||||
m_text_x_alignment, x_pos, m_text_y_alignment, y_pos,
|
x_pos, y_pos,
|
||||||
255, 255, 255, m_text_scale, m_text_scale);
|
255, 255, 255, m_text_scale, m_text_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +471,7 @@ void Widget::resize_to_text()
|
|||||||
font_gui->getBBox(m_text.c_str(), m_text_size, false, &left, &right, &bottom, &top);
|
font_gui->getBBox(m_text.c_str(), m_text_size, false, &left, &right, &bottom, &top);
|
||||||
|
|
||||||
const int TEXT_WIDTH = (int)(right - left);
|
const int TEXT_WIDTH = (int)(right - left);
|
||||||
const int TEXT_HEIGHT = (int)(bottom - top);
|
const int TEXT_HEIGHT = (int)(top - bottom);
|
||||||
|
|
||||||
if( TEXT_WIDTH > m_width ) m_width = TEXT_WIDTH;
|
if( TEXT_WIDTH > m_width ) m_width = TEXT_WIDTH;
|
||||||
if( TEXT_HEIGHT > m_height ) m_height = TEXT_HEIGHT;
|
if( TEXT_HEIGHT > m_height ) m_height = TEXT_HEIGHT;
|
||||||
|
@ -50,6 +50,24 @@ enum WidgetArea //One of the uses of this, is for rounded corners
|
|||||||
WGT_AREA_ALL = (WGT_AREA_TOP | WGT_AREA_BOT)
|
WGT_AREA_ALL = (WGT_AREA_TOP | WGT_AREA_BOT)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//The lowest scroll values here must be bigger or lower than
|
||||||
|
//Widget::MAX_SCROLL
|
||||||
|
enum WidgetScrollPos
|
||||||
|
{
|
||||||
|
//For the X axis
|
||||||
|
WGT_SCROLL_START_LEFT = 2000001,
|
||||||
|
WGT_SCROLL_START_RIGHT = 2000002,
|
||||||
|
WGT_SCROLL_END_LEFT = -2000001,
|
||||||
|
WGT_SCROLL_END_RIGHT = -2000002,
|
||||||
|
//For the Y axis
|
||||||
|
WGT_SCROLL_START_TOP = 1000001,
|
||||||
|
WGT_SCROLL_START_BOTTOM = 1000002,
|
||||||
|
WGT_SCROLL_END_TOP = -1000001,
|
||||||
|
WGT_SCROLL_END_BOTTOM = -1000002,
|
||||||
|
//Works for both axis
|
||||||
|
WGT_SCROLL_CENTER = 3000000
|
||||||
|
};
|
||||||
|
|
||||||
//I suggest that you do not use the white or light colors for the rects in
|
//I suggest that you do not use the white or light colors for the rects in
|
||||||
//most cases, because they don't have lighter versions that can be used to
|
//most cases, because they don't have lighter versions that can be used to
|
||||||
//highlight those rects and then revert them, for example, when you select a
|
//highlight those rects and then revert them, for example, when you select a
|
||||||
@ -86,6 +104,9 @@ extern const GLfloat WGT_LIGHT_TRANS_BLUE [4];
|
|||||||
|
|
||||||
class Widget
|
class Widget
|
||||||
{
|
{
|
||||||
|
//The only class that can access the Widget class is WidgetManager;
|
||||||
|
//they are meant to always be used together, and the widgets should only
|
||||||
|
//be used through the WidgetManager class.
|
||||||
friend class WidgetManager;
|
friend class WidgetManager;
|
||||||
|
|
||||||
/* Basic widget properties that will always be used. */
|
/* Basic widget properties that will always be used. */
|
||||||
@ -107,15 +128,14 @@ class Widget
|
|||||||
bool m_enable_text;
|
bool m_enable_text;
|
||||||
std::string m_text;
|
std::string m_text;
|
||||||
WidgetFontSize m_text_size;
|
WidgetFontSize m_text_size;
|
||||||
Font::FontAlignType m_text_x_alignment;
|
|
||||||
Font::FontAlignType m_text_y_alignment;
|
|
||||||
|
|
||||||
|
|
||||||
|
static const int MAX_SCROLL;
|
||||||
bool m_enable_scroll;
|
bool m_enable_scroll;
|
||||||
/* int m_scroll_pos_x;*/
|
float m_scroll_pos_x;
|
||||||
int m_scroll_pos_y;
|
float m_scroll_pos_y;
|
||||||
/* int m_scroll_speed_x;*/
|
float m_scroll_speed_x;
|
||||||
int m_scroll_speed_y;
|
float m_scroll_speed_y;
|
||||||
|
|
||||||
/* Delta time dependant features, these deactivate after a certain time,
|
/* Delta time dependant features, these deactivate after a certain time,
|
||||||
* and are dependant on the delta time. They have animations. */
|
* and are dependant on the delta time. They have animations. */
|
||||||
|
@ -80,13 +80,11 @@ bool WidgetManager::add_wgt
|
|||||||
new_id.widget->m_enable_text = m_default_show_text;
|
new_id.widget->m_enable_text = m_default_show_text;
|
||||||
new_id.widget->m_text.assign(m_default_text);
|
new_id.widget->m_text.assign(m_default_text);
|
||||||
new_id.widget->m_text_size = m_default_text_size;
|
new_id.widget->m_text_size = m_default_text_size;
|
||||||
new_id.widget->m_text_x_alignment = m_default_text_x_alignment;
|
|
||||||
new_id.widget->m_text_y_alignment = m_default_text_y_alignment;
|
|
||||||
|
|
||||||
new_id.widget->m_enable_scroll = m_default_enable_scroll;
|
new_id.widget->m_enable_scroll = m_default_enable_scroll;
|
||||||
/* new_id.widget->m_scroll_pos_x = m_default_scroll_x_pos;*/
|
new_id.widget->m_scroll_pos_x = m_default_scroll_x_pos;
|
||||||
new_id.widget->m_scroll_pos_y = m_default_scroll_y_pos;
|
new_id.widget->m_scroll_pos_y = m_default_scroll_y_pos;
|
||||||
/* new_id.widget->m_scroll_speed_x = m_default_scroll_x_speed;*/
|
new_id.widget->m_scroll_speed_x = m_default_scroll_x_speed;
|
||||||
new_id.widget->m_scroll_speed_y = m_default_scroll_y_speed;
|
new_id.widget->m_scroll_speed_y = m_default_scroll_y_speed;
|
||||||
|
|
||||||
m_elems.push_back(WidgetElement(ET_WGT, m_widgets.size()));
|
m_elems.push_back(WidgetElement(ET_WGT, m_widgets.size()));
|
||||||
@ -730,32 +728,28 @@ void WidgetManager::set_initial_text_state
|
|||||||
(
|
(
|
||||||
const bool SHOW,
|
const bool SHOW,
|
||||||
const std::string TEXT,
|
const std::string TEXT,
|
||||||
const WidgetFontSize SIZE,
|
const WidgetFontSize SIZE
|
||||||
const Font::FontAlignType X_ALIGN,
|
|
||||||
const Font::FontAlignType Y_ALIGN
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
m_default_show_text = SHOW;
|
m_default_show_text = SHOW;
|
||||||
m_default_text = TEXT;
|
m_default_text = TEXT;
|
||||||
m_default_text_size = SIZE;
|
m_default_text_size = SIZE;
|
||||||
m_default_text_x_alignment = X_ALIGN;
|
|
||||||
m_default_text_y_alignment = Y_ALIGN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void WidgetManager::set_initial_scroll_state
|
void WidgetManager::set_initial_scroll_state
|
||||||
(
|
(
|
||||||
const bool ENABLE,
|
const bool ENABLE,
|
||||||
/* const int X_POS,*/
|
const int X_POS,
|
||||||
const int Y_POS,
|
const int Y_POS,
|
||||||
/* const int X_SPEED,*/
|
const int X_SPEED,
|
||||||
const int Y_SPEED
|
const int Y_SPEED
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
m_default_enable_scroll = ENABLE;
|
m_default_enable_scroll = ENABLE;
|
||||||
/* m_default_scroll_x_pos = X_POS;*/
|
m_default_scroll_x_pos = X_POS;
|
||||||
m_default_scroll_y_pos = Y_POS;
|
m_default_scroll_y_pos = Y_POS;
|
||||||
/* m_default_scroll_x_speed = X_SPEED;*/
|
m_default_scroll_x_speed = X_SPEED;
|
||||||
m_default_scroll_y_speed = Y_SPEED;
|
m_default_scroll_y_speed = Y_SPEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,12 +765,10 @@ void WidgetManager::restore_default_states()
|
|||||||
m_default_show_text = false;
|
m_default_show_text = false;
|
||||||
m_default_text = "";
|
m_default_text = "";
|
||||||
m_default_text_size = WGT_FNT_MED;
|
m_default_text_size = WGT_FNT_MED;
|
||||||
m_default_text_x_alignment = Font::ALIGN_CENTER;
|
|
||||||
m_default_text_y_alignment = Font::ALIGN_CENTER;
|
|
||||||
m_default_enable_scroll = false;
|
m_default_enable_scroll = false;
|
||||||
/* m_default_scroll_x_pos = 0;*/
|
m_default_scroll_x_pos = WGT_SCROLL_CENTER;
|
||||||
m_default_scroll_y_pos = 0;
|
m_default_scroll_y_pos = WGT_SCROLL_CENTER;
|
||||||
/* m_default_scroll_x_speed = 0;*/
|
m_default_scroll_x_speed = 0;
|
||||||
m_default_scroll_y_speed = 0;
|
m_default_scroll_y_speed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -972,6 +964,7 @@ void WidgetManager::hide_wgt_text( const int TOKEN )
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
void WidgetManager::set_wgt_text_x_alignment( const int TOKEN, const Font::FontAlignType ALIGN )
|
void WidgetManager::set_wgt_text_x_alignment( const int TOKEN, const Font::FontAlignType ALIGN )
|
||||||
{
|
{
|
||||||
const int ID = find_id(TOKEN);
|
const int ID = find_id(TOKEN);
|
||||||
@ -982,9 +975,9 @@ void WidgetManager::set_wgt_text_x_alignment( const int TOKEN, const Font::FontA
|
|||||||
"an unnamed widget with token " << TOKEN << '\n';
|
"an unnamed widget with token " << TOKEN << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void WidgetManager::set_wgt_text_y_alignment( const int TOKEN, const Font::FontAlignType ALIGN )
|
/*void WidgetManager::set_wgt_text_y_alignment( const int TOKEN, const Font::FontAlignType ALIGN )
|
||||||
{
|
{
|
||||||
const int ID = find_id(TOKEN);
|
const int ID = find_id(TOKEN);
|
||||||
if( ID != WGT_NONE ) m_widgets[ID].widget->m_text_y_alignment = ALIGN;
|
if( ID != WGT_NONE ) m_widgets[ID].widget->m_text_y_alignment = ALIGN;
|
||||||
@ -993,7 +986,7 @@ void WidgetManager::set_wgt_text_y_alignment( const int TOKEN, const Font::FontA
|
|||||||
std::cerr << "WARNING: tried to set the Y alignment of text of " <<
|
std::cerr << "WARNING: tried to set the Y alignment of text of " <<
|
||||||
"an unnamed widget with token " << TOKEN << '\n';
|
"an unnamed widget with token " << TOKEN << '\n';
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void WidgetManager::enable_wgt_scroll( const int TOKEN )
|
void WidgetManager::enable_wgt_scroll( const int TOKEN )
|
||||||
@ -1020,16 +1013,46 @@ void WidgetManager::disable_wgt_scroll( const int TOKEN )
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/*void WidgetManager::set_wgt_x_scroll_pos( const int TOKEN, const int POS )
|
void WidgetManager::set_wgt_x_scroll_pos
|
||||||
|
(
|
||||||
|
const int TOKEN,
|
||||||
|
const WidgetScrollPos POS
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
if( POS == WGT_SCROLL_START_TOP || POS == WGT_SCROLL_START_BOTTOM ||
|
||||||
|
POS == WGT_SCROLL_END_TOP || POS == WGT_SCROLL_END_BOTTOM )
|
||||||
|
{
|
||||||
|
std::cerr << "WARNING: tried to set the X scroll position to a " <<
|
||||||
|
"position for the Y axis, on widget with token " << TOKEN <<
|
||||||
|
'\n';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const int ID = find_id(TOKEN);
|
const int ID = find_id(TOKEN);
|
||||||
if( ID != WGT_NONE ) m_widgets[ID].widget->m_scroll_pos_x = POS;
|
if( ID != WGT_NONE ) m_widgets[ID].widget->m_scroll_pos_x = POS;
|
||||||
else std::cerr << "Tried to set the X scroll position of an unnamed widget with token " << TOKEN << '\n';
|
else
|
||||||
}*/
|
{
|
||||||
|
std::cerr << "WARNING: tried to set the X scroll position of an " <<
|
||||||
|
"unnamed widget with token " << TOKEN << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void WidgetManager::set_wgt_y_scroll_pos( const int TOKEN, const int POS )
|
void WidgetManager::set_wgt_y_scroll_pos
|
||||||
|
(
|
||||||
|
const int TOKEN,
|
||||||
|
const WidgetScrollPos POS
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
if( POS == WGT_SCROLL_START_LEFT || POS == WGT_SCROLL_START_RIGHT ||
|
||||||
|
POS == WGT_SCROLL_END_LEFT || POS == WGT_SCROLL_END_RIGHT )
|
||||||
|
{
|
||||||
|
std::cerr << "WARNING: tried to set the Y scroll position to a " <<
|
||||||
|
"position for the X axis, on widget with token " << TOKEN <<
|
||||||
|
'\n';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const int ID = find_id(TOKEN);
|
const int ID = find_id(TOKEN);
|
||||||
if( ID != WGT_NONE ) m_widgets[ID].widget->m_scroll_pos_y = POS;
|
if( ID != WGT_NONE ) m_widgets[ID].widget->m_scroll_pos_y = POS;
|
||||||
else
|
else
|
||||||
@ -1040,15 +1063,19 @@ void WidgetManager::set_wgt_y_scroll_pos( const int TOKEN, const int POS )
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/*void WidgetManager::set_wgt_x_scroll_speed( const int TOKEN, const int SPEED )
|
void WidgetManager::set_wgt_x_scroll_speed( const int TOKEN, const float SPEED )
|
||||||
{
|
{
|
||||||
const int ID = find_id(TOKEN);
|
const int ID = find_id(TOKEN);
|
||||||
if( ID != WGT_NONE ) m_widgets[ID].widget->m_scroll_speed_x = SPEED;
|
if( ID != WGT_NONE ) m_widgets[ID].widget->m_scroll_speed_x = SPEED;
|
||||||
else std::cerr << "Tried to set the X scroll speed of an unnamed widget with token " << TOKEN << '\n';
|
else
|
||||||
}*/
|
{
|
||||||
|
std::cerr << "WARNING: tried to set the X scroll speed of an " <<
|
||||||
|
"unnamed widget with token " << TOKEN << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void WidgetManager::set_wgt_y_scroll_speed( const int TOKEN, const int SPEED )
|
void WidgetManager::set_wgt_y_scroll_speed( const int TOKEN, const float SPEED )
|
||||||
{
|
{
|
||||||
const int ID = find_id(TOKEN);
|
const int ID = find_id(TOKEN);
|
||||||
if( ID != WGT_NONE ) m_widgets[ID].widget->m_scroll_speed_y = SPEED;
|
if( ID != WGT_NONE ) m_widgets[ID].widget->m_scroll_speed_y = SPEED;
|
||||||
|
@ -97,13 +97,11 @@ class WidgetManager
|
|||||||
bool m_default_show_text;
|
bool m_default_show_text;
|
||||||
std::string m_default_text;
|
std::string m_default_text;
|
||||||
WidgetFontSize m_default_text_size;
|
WidgetFontSize m_default_text_size;
|
||||||
Font::FontAlignType m_default_text_x_alignment;
|
|
||||||
Font::FontAlignType m_default_text_y_alignment;
|
|
||||||
|
|
||||||
bool m_default_enable_scroll;
|
bool m_default_enable_scroll;
|
||||||
/* int m_default_scroll_x_pos;*/
|
int m_default_scroll_x_pos;
|
||||||
int m_default_scroll_y_pos;
|
int m_default_scroll_y_pos;
|
||||||
/* int m_default_scroll_x_speed;*/
|
int m_default_scroll_x_speed;
|
||||||
int m_default_scroll_y_speed;
|
int m_default_scroll_y_speed;
|
||||||
|
|
||||||
bool is_column_break( const int BREAK_POST ) const;
|
bool is_column_break( const int BREAK_POST ) const;
|
||||||
@ -169,11 +167,16 @@ public:
|
|||||||
(
|
(
|
||||||
const bool SHOW,
|
const bool SHOW,
|
||||||
const std::string TEXT,
|
const std::string TEXT,
|
||||||
const WidgetFontSize SIZE,
|
const WidgetFontSize SIZE
|
||||||
const Font::FontAlignType X_ALIGN,
|
);
|
||||||
const Font::FontAlignType Y_ALIGN
|
void set_initial_scroll_state
|
||||||
|
(
|
||||||
|
const bool ENABLE,
|
||||||
|
const int X_POS,
|
||||||
|
const int Y_POS,
|
||||||
|
const int X_SPEED,
|
||||||
|
const int Y_SPEED
|
||||||
);
|
);
|
||||||
void set_initial_scroll_state(const bool ENABLE, /*const int X_POS,*/ const int Y_POS, /*const int X_SPEED, */const int Y_SPEED );
|
|
||||||
void restore_default_states();
|
void restore_default_states();
|
||||||
|
|
||||||
void activate_wgt(const int TOKEN);
|
void activate_wgt(const int TOKEN);
|
||||||
@ -197,15 +200,17 @@ public:
|
|||||||
void show_wgt_text( const int TOKEN );
|
void show_wgt_text( const int TOKEN );
|
||||||
void hide_wgt_text( const int TOKEN );
|
void hide_wgt_text( const int TOKEN );
|
||||||
// void toggle_wgt_text( const int TOKEN );
|
// void toggle_wgt_text( const int TOKEN );
|
||||||
void set_wgt_text_x_alignment( const int TOKEN, const Font::FontAlignType ALIGN );
|
|
||||||
void set_wgt_text_y_alignment( const int TOKEN, const Font::FontAlignType ALIGN );
|
|
||||||
|
|
||||||
|
//FIXME: change to enable_wgt_scrolling, since it enables or disables
|
||||||
|
//FIXME: maybe all that enabling the scrolling should do, is to allow
|
||||||
|
//players to lower/raise it?
|
||||||
|
//only the scrolling movement, not setting the scrolling position.
|
||||||
void enable_wgt_scroll( const int TOKEN );
|
void enable_wgt_scroll( const int TOKEN );
|
||||||
void disable_wgt_scroll( const int TOKEN );
|
void disable_wgt_scroll( const int TOKEN );
|
||||||
/* void set_wgt_x_scroll_pos( const int TOKEN, const int POS );*/
|
void set_wgt_x_scroll_pos( const int TOKEN, const WidgetScrollPos POS );
|
||||||
void set_wgt_y_scroll_pos( const int TOKEN, const int POS );
|
void set_wgt_y_scroll_pos( const int TOKEN, const WidgetScrollPos POS );
|
||||||
/* void set_wgt_x_scroll_speed( const int TOKEN, const int SPEED );*/
|
void set_wgt_x_scroll_speed( const int TOKEN, const float SPEED );
|
||||||
void set_wgt_y_scroll_speed( const int TOKEN, const int SPEED );
|
void set_wgt_y_scroll_speed( const int TOKEN, const float SPEED );
|
||||||
|
|
||||||
/* Activated widget features. */
|
/* Activated widget features. */
|
||||||
void pulse_wgt( const int TOKEN ) const;
|
void pulse_wgt( const int TOKEN ) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user