Rewritten a few more menus to use SFML. Fixed issue in DrawFrame
git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/branches/SFML2@472 0420edf4-82e4-42fc-9478-35b55e6d67a3master
parent
a9ace1a9c1
commit
884206dbc8
|
@ -39,7 +39,7 @@ GNU General Public License for more details.
|
|||
CEvent Event;
|
||||
|
||||
// ready: 0 - racing 1 - ready with success 2 - ready with failure
|
||||
static int ready = 0; // indicates if last race is done
|
||||
static int ready = 0; // indicates if last race is done
|
||||
static TWidget* curr_focus = 0;
|
||||
static TCup2 *ecup = 0;
|
||||
static size_t curr_race = 0;
|
||||
|
@ -140,6 +140,9 @@ static TArea area;
|
|||
static int messtop, messtop2;
|
||||
static int bonustop, framewidth, frametop, framebottom;
|
||||
static int dist, texsize;
|
||||
static sf::Text* headline;
|
||||
static sf::Text* info1;
|
||||
static sf::Text* info2;
|
||||
|
||||
void CEvent::Enter () {
|
||||
Winsys.ShowCursor (!param.ice_cursor);
|
||||
|
@ -165,11 +168,40 @@ void CEvent::Enter () {
|
|||
textbuttons[0] = AddTextButton (Trans.Text(13), area.right -len - 100, AutoYPosN (80), siz);
|
||||
textbuttons[2] = AddTextButton (Trans.Text(15), CENTER, AutoYPosN (80), siz);
|
||||
|
||||
FT.AutoSizeN(6);
|
||||
headline = new sf::Text(ecup->name, FT.getCurrentFont(), FT.GetSize());
|
||||
headline->setPosition((Winsys.resolution.width - headline->getLocalBounds().width) / 2, AutoYPosN(25));
|
||||
|
||||
FT.AutoSizeN(3);
|
||||
int ddd = FT.AutoDistanceN(1);
|
||||
string info = Trans.Text(11);
|
||||
info += " " + Int_StrN(ecup->races[curr_race]->herrings.x);
|
||||
info += " " + Int_StrN(ecup->races[curr_race]->herrings.y);
|
||||
info += " " + Int_StrN(ecup->races[curr_race]->herrings.z);
|
||||
info1 = new sf::Text(info, FT.getCurrentFont(), FT.GetSize());
|
||||
info1->setPosition((Winsys.resolution.width - info1->getLocalBounds().width) / 2, framebottom + 15);
|
||||
info1->setColor(sf::Color(colDBlue.r * 255, colDBlue.g * 255, colDBlue.b * 255, colDBlue.a * 255));
|
||||
|
||||
info = Trans.Text(12);
|
||||
info += " " + Float_StrN(ecup->races[curr_race]->time.x, 0);
|
||||
info += " " + Float_StrN(ecup->races[curr_race]->time.y, 0);
|
||||
info += " " + Float_StrN(ecup->races[curr_race]->time.z, 0);
|
||||
info += " " + Trans.Text(14);
|
||||
info2 = new sf::Text(info, FT.getCurrentFont(), FT.GetSize());
|
||||
info2->setPosition((Winsys.resolution.width - info2->getLocalBounds().width) / 2, framebottom + 15 + ddd);
|
||||
info2->setColor(sf::Color(colDBlue.r * 255, colDBlue.g * 255, colDBlue.b * 255, colDBlue.a * 255));
|
||||
|
||||
Music.Play (param.menu_music, -1);
|
||||
if (ready < 1) curr_focus = textbuttons[0];
|
||||
else curr_focus = textbuttons[2];
|
||||
}
|
||||
|
||||
void CEvent::Exit() {
|
||||
delete headline;
|
||||
delete info1;
|
||||
delete info2;
|
||||
}
|
||||
|
||||
int resultlevel (size_t num, size_t numraces) {
|
||||
if (num < 1) return 0;
|
||||
int q = (int)((num - 0.01) / numraces);
|
||||
|
@ -194,15 +226,14 @@ void CEvent::Loop (double timestep) {
|
|||
// 0, colMBackgr, colBlack, 0.2);
|
||||
|
||||
if (ready == 0) { // cup not finished
|
||||
FT.AutoSizeN (6);
|
||||
FT.SetColor (colWhite);
|
||||
FT.DrawString (CENTER, AutoYPosN (25), ecup->name);
|
||||
Winsys.draw(*headline);
|
||||
|
||||
DrawBonusExt (bonustop, (int)ecup->races.size(), curr_bonus);
|
||||
|
||||
DrawFrameX (area.left, frametop, framewidth,
|
||||
(int)ecup->races.size() * dist + 20, 3, colBackgr, colWhite, 1);
|
||||
|
||||
TCheckbox checkbox(area.right - 50, frametop, texsize, "");
|
||||
for (size_t i=0; i<ecup->races.size(); i++) {
|
||||
FT.AutoSizeN (3);
|
||||
|
||||
|
@ -212,26 +243,12 @@ void CEvent::Loop (double timestep) {
|
|||
else
|
||||
FT.SetColor (colWhite);
|
||||
FT.DrawString (area.left + 29, y, Course.CourseList[ecup->races[i]->course].name);
|
||||
Tex.Draw (CHECKBOX, area.right -54, y, texsize, texsize);
|
||||
if (curr_race > i) Tex.Draw (CHECKMARK, area.right-50, y + 4, 0.8);
|
||||
checkbox.SetPosition(area.right - 50, y + 4);
|
||||
checkbox.SetChecked(curr_race > i);
|
||||
checkbox.Draw();
|
||||
}
|
||||
|
||||
FT.AutoSizeN (3);
|
||||
int ddd = FT.AutoDistanceN (1);
|
||||
FT.SetColor (colDBlue);
|
||||
string info = Trans.Text(11);
|
||||
info += " " + Int_StrN (ecup->races[curr_race]->herrings.x);
|
||||
info += " " + Int_StrN (ecup->races[curr_race]->herrings.y);
|
||||
info += " " + Int_StrN (ecup->races[curr_race]->herrings.z);
|
||||
FT.DrawString (CENTER, framebottom+15, info);
|
||||
|
||||
info = Trans.Text(12);
|
||||
info += " " + Float_StrN (ecup->races[curr_race]->time.x, 0);
|
||||
info += " " + Float_StrN (ecup->races[curr_race]->time.y, 0);
|
||||
info += " " + Float_StrN (ecup->races[curr_race]->time.z, 0);
|
||||
info += " " + Trans.Text(14);
|
||||
FT.DrawString (CENTER, framebottom+15+ddd, info);
|
||||
|
||||
Winsys.draw(*info1);
|
||||
Winsys.draw(*info2);
|
||||
} else if (ready == 1) { // cup successfully finished
|
||||
FT.AutoSizeN (5);
|
||||
FT.SetColor (colWhite);
|
||||
|
|
|
@ -23,6 +23,7 @@ GNU General Public License for more details.
|
|||
|
||||
class CEvent : public State {
|
||||
void Enter();
|
||||
void Exit();
|
||||
void Loop(double time_step);
|
||||
void Keyb(sf::Keyboard::Key key, bool special, bool release, int x, int y);
|
||||
void Mouse(int button, int state, int x, int y);
|
||||
|
|
|
@ -88,6 +88,11 @@ void CEventSelect::Motion (int x, int y) {
|
|||
// --------------------------------------------------------------------
|
||||
static TArea area;
|
||||
static int framewidth, frameheight, frametop1, frametop2;
|
||||
static sf::Text selectEvent;
|
||||
static sf::Text selectCup;
|
||||
static sf::Text selectedEvent;
|
||||
static sf::Text selectedCup;
|
||||
static sf::Text cupLocked;
|
||||
|
||||
void CEventSelect::Enter () {
|
||||
Winsys.ShowCursor (!param.ice_cursor);
|
||||
|
@ -111,6 +116,30 @@ void CEventSelect::Enter () {
|
|||
textbuttons[1] = AddTextButton (Trans.Text(8), area.left+50, AutoYPosN (70), siz);
|
||||
SetFocus(textbuttons[1]);
|
||||
|
||||
FT.AutoSizeN(3);
|
||||
selectEvent.setString(Trans.Text(6));
|
||||
selectEvent.setCharacterSize(FT.GetSize());
|
||||
selectEvent.setFont(FT.getCurrentFont());
|
||||
selectEvent.setPosition(area.left, AutoYPosN(30));
|
||||
selectCup.setString(Trans.Text(7));
|
||||
selectCup.setCharacterSize(FT.GetSize());
|
||||
selectCup.setFont(FT.getCurrentFont());
|
||||
selectCup.setPosition(area.left, AutoYPosN(45));
|
||||
cupLocked.setString(Trans.Text(10));
|
||||
cupLocked.setCharacterSize(FT.GetSize());
|
||||
cupLocked.setFont(FT.getCurrentFont());
|
||||
cupLocked.setColor(sf::Color(colLGrey.r * 255, colLGrey.g * 255, colLGrey.b * 255, colLGrey.a * 255));
|
||||
cupLocked.setPosition((Winsys.resolution.width - cupLocked.getLocalBounds().width) / 2, AutoYPosN(58));
|
||||
|
||||
FT.AutoSizeN(4);
|
||||
selectedEvent.setCharacterSize(FT.GetSize());
|
||||
selectedEvent.setFont(FT.getCurrentFont());
|
||||
selectedEvent.setPosition(area.left + 20, frametop1+2);
|
||||
selectedEvent.setColor(sf::Color(colDYell.r * 255, colDYell.g * 255, colDYell.b * 255, colDYell.a * 255));
|
||||
selectedCup.setCharacterSize(FT.GetSize());
|
||||
selectedCup.setFont(FT.getCurrentFont());
|
||||
selectedCup.setPosition(area.left + 20, frametop2+2);
|
||||
|
||||
Events.MakeUnlockList (Players.GetCurrUnlocked());
|
||||
Music.Play (param.menu_music, -1);
|
||||
}
|
||||
|
@ -131,34 +160,27 @@ void CEventSelect::Loop (double timestep) {
|
|||
|
||||
DrawGUIBackground(Winsys.scale);
|
||||
|
||||
// DrawFrameX (area.left, area.top, area.right-area.left, area.bottom - area.top,
|
||||
// 0, colMBackgr, colBlack, 0.2);
|
||||
|
||||
FT.AutoSizeN (3);
|
||||
FT.SetColor (colWhite);
|
||||
FT.DrawString (area.left, AutoYPosN (30), Trans.Text (6));
|
||||
FT.DrawString (area.left,AutoYPosN (45), Trans.Text (7));
|
||||
if (Events.IsUnlocked (event->GetValue(), cup->GetValue()) == false) {
|
||||
FT.SetColor (colLGrey);
|
||||
FT.DrawString (CENTER, AutoYPosN (58), Trans.Text (10));
|
||||
}
|
||||
|
||||
FT.AutoSizeN (4);
|
||||
Winsys.draw(selectEvent);
|
||||
Winsys.draw(selectCup);
|
||||
if (Events.IsUnlocked(event->GetValue(), cup->GetValue()) == false)
|
||||
Winsys.draw(cupLocked);
|
||||
|
||||
if (event->focussed()) col = colDYell;
|
||||
else col = colWhite;
|
||||
DrawFrameX (area.left, frametop1, framewidth, frameheight, 3, colMBackgr, col, 1.0);
|
||||
FT.SetColor (colDYell);
|
||||
FT.DrawString (area.left + 20, frametop1, EventList[event->GetValue()].name);
|
||||
DrawFrameX(area.left, frametop1, framewidth, frameheight, 3, colMBackgr, col, 1.0);
|
||||
selectedEvent.setString(EventList[event->GetValue()].name);
|
||||
Winsys.draw(selectedEvent);
|
||||
|
||||
if (cup->focussed()) col = colDYell;
|
||||
else col = colWhite;
|
||||
DrawFrameX (area.left, frametop2, framewidth, frameheight, 3, colMBackgr, col, 1.0);
|
||||
if (Events.IsUnlocked (event->GetValue(), cup->GetValue()))
|
||||
FT.SetColor (colDYell);
|
||||
col = colDYell;
|
||||
else
|
||||
FT.SetColor (colLGrey);
|
||||
FT.DrawString (area.left + 20, frametop2, Events.GetCupTrivialName (event->GetValue(), cup->GetValue()));
|
||||
col = colLGrey;
|
||||
selectedCup.setColor(sf::Color(col.r * 255, col.g * 255, col.b * 255, col.a * 255));
|
||||
selectedCup.setString(Events.GetCupTrivialName(event->GetValue(), cup->GetValue()));
|
||||
Winsys.draw(selectedCup);
|
||||
|
||||
textbuttons[0]->SetActive(Events.IsUnlocked (event->GetValue(), cup->GetValue()));
|
||||
DrawGUI();
|
||||
|
|
|
@ -223,8 +223,7 @@ void CGameOver::Loop(double time_step) {
|
|||
ScopedRenderMode rm(GUI);
|
||||
if (final_frame != NULL) {
|
||||
if (!final_frame->active) GameOverMessage(ctrl);
|
||||
}
|
||||
else GameOverMessage(ctrl);
|
||||
} else GameOverMessage(ctrl);
|
||||
}
|
||||
Setup2dScene();
|
||||
DrawHud (ctrl);
|
||||
|
|
|
@ -196,6 +196,12 @@ TCheckbox::TCheckbox(int x, int y, int width, const sf::String& tag_)
|
|||
mouseRect.left = x + width - 32;
|
||||
}
|
||||
|
||||
void TCheckbox::SetPosition(int x, int y) {
|
||||
text.setPosition(x, y);
|
||||
back.setPosition(x, y);
|
||||
checkmark.setPosition(x, y);
|
||||
}
|
||||
|
||||
void TCheckbox::Focussed() {
|
||||
if (focus)
|
||||
text.setColor(sf::Color(colDYell.r * 255, colDYell.g * 255, colDYell.b * 255, colDYell.a * 255));
|
||||
|
@ -509,7 +515,7 @@ void DrawGUIBackground(float logoScale) {
|
|||
|
||||
static sf::Sprite logo(Tex.GetSFTexture(T_TITLE_SMALL));
|
||||
logo.setScale(logoScale, logoScale);
|
||||
logo.setPosition((Winsys.resolution.width - logo.getTextureRect().width) /2, (5));
|
||||
logo.setPosition((Winsys.resolution.width - logo.getTextureRect().width) /2, 5);
|
||||
Winsys.draw(logo);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,8 @@ public:
|
|||
|
||||
TCheckbox(int x, int y, int width_, const sf::String& tag_);
|
||||
void Draw() const;
|
||||
void SetPosition(int x, int y);
|
||||
void SetChecked(bool c) { checked = c; }
|
||||
void Focussed();
|
||||
bool Click(int x, int y);
|
||||
void Key(sf::Keyboard::Key key, unsigned int mod, bool released);
|
||||
|
|
|
@ -176,12 +176,12 @@ void TTexture::Draw(int x, int y, float width, float height, Orientation orienta
|
|||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void TTexture::DrawFrame(int x, int y, double w, double h, int frame, const TColor& col) {
|
||||
void TTexture::DrawFrame(int x, int y, int w, int h, int frame, const TColor& col) {
|
||||
if (w < 1) w = texture.getSize().x;
|
||||
if (h < 1) h = texture.getSize().y;
|
||||
|
||||
if (frame > 0)
|
||||
DrawFrameX(x - frame, y - frame, w + 2 * frame + 1, h + 2 * frame + 1, frame, colTransp, col, 1.0);
|
||||
DrawFrameX(x - frame, y - frame, w + 2 * frame, h + 2 * frame, frame, colTransp, col, 1.0);
|
||||
|
||||
sf::Sprite temp(texture);
|
||||
temp.setPosition(x, y);
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
void Draw();
|
||||
void Draw(int x, int y, float size, Orientation orientation);
|
||||
void Draw(int x, int y, float width, float height, Orientation orientation);
|
||||
void DrawFrame(int x, int y, double w, double h, int frame, const TColor& col);
|
||||
void DrawFrame(int x, int y, int w, int h, int frame, const TColor& col);
|
||||
};
|
||||
|
||||
class CTexture {
|
||||
|
|
Loading…
Reference in New Issue