Correct quirks with drawrect and fillrect, change UI components accordingly, shorten save name in save button

This commit is contained in:
Simon Robertshaw
2012-04-22 17:13:43 +01:00
parent 553cf65520
commit e38fd405af
11 changed files with 93 additions and 60 deletions

View File

@@ -323,22 +323,24 @@ void Graphics::draw_line(int x, int y, int x2, int y2, int r, int g, int b, int
void Graphics::drawrect(int x, int y, int width, int height, int r, int g, int b, int a) void Graphics::drawrect(int x, int y, int width, int height, int r, int g, int b, int a)
{ {
x++; x++;
height--;
width--;
glColor4ub(r, g, b, a); glColor4ub(r, g, b, a);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
glVertex2i(x, y); glVertex2f(x, y);
glVertex2i(x+width, y); glVertex2f(x+width, y);
glVertex2i(x+width, y+height); glVertex2f(x+width, y+height);
glVertex2i(x, y+height+1); //+1 is a hack to prevent squares from missing their corners, will make smoothed lines look like SHIT glVertex2f(x, y+height+1); //+1 is a hack to prevent squares from missing their corners, will make smoothed lines look like SHIT
glVertex2i(x, y); glVertex2f(x, y);
glEnd(); glEnd();
} }
void Graphics::fillrect(int x, int y, int width, int height, int r, int g, int b, int a) void Graphics::fillrect(int x, int y, int width, int height, int r, int g, int b, int a)
{ {
x++; /*x++;
y++; y++;
width-=1; width-=1;
height-=1; height-=1;*/
glColor4ub(r, g, b, a); glColor4ub(r, g, b, a);
glBegin(GL_QUADS); glBegin(GL_QUADS);

View File

@@ -35,6 +35,7 @@ extern "C" IMAGE_DOS_HEADER __ImageBase;
SDL_Surface * SDLOpen() SDL_Surface * SDLOpen()
{ {
SDL_Surface * surface;
#if defined(WIN32) && defined(WINCONSOLE) #if defined(WIN32) && defined(WINCONSOLE)
FILE * console = fopen("CON", "w" ); FILE * console = fopen("CON", "w" );
#endif #endif
@@ -75,10 +76,21 @@ SDL_Surface * SDLOpen()
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
atexit(SDL_Quit); atexit(SDL_Quit);
#ifndef OGLR #ifndef OGLR
return SDL_SetVideoMode(XRES + BARSIZE, YRES + MENUSIZE, 32, SDL_SWSURFACE); surface = SDL_SetVideoMode(XRES + BARSIZE, YRES + MENUSIZE, 32, SDL_SWSURFACE);
#else #else
return SDL_SetVideoMode(XRES + BARSIZE, YRES + MENUSIZE, 32, SDL_OPENGL); surface = SDL_SetVideoMode(XRES + BARSIZE, YRES + MENUSIZE, 32, SDL_OPENGL);
#endif #endif
#if defined(WIN32) && defined(OGLR)
int status = glewInit();
if(status != GLEW_OK)
{
fprintf(stderr, "Initializing Glew: %d\n", status);
exit(-1);
}
#endif
return surface;
} }
/*int SDLPoll(SDL_Event * event) /*int SDLPoll(SDL_Event * event)

View File

@@ -321,6 +321,8 @@ void Graphics::draw_line(int x1, int y1, int x2, int y2, int r, int g, int b, in
void Graphics::drawrect(int x, int y, int w, int h, int r, int g, int b, int a) void Graphics::drawrect(int x, int y, int w, int h, int r, int g, int b, int a)
{ {
int i; int i;
w--;
h--;
for (i=0; i<=w; i++) for (i=0; i<=w; i++)
{ {
blendpixel(x+i, y, r, g, b, a); blendpixel(x+i, y, r, g, b, a);
@@ -336,8 +338,8 @@ void Graphics::drawrect(int x, int y, int w, int h, int r, int g, int b, int a)
void Graphics::fillrect(int x, int y, int w, int h, int r, int g, int b, int a) void Graphics::fillrect(int x, int y, int w, int h, int r, int g, int b, int a)
{ {
int i,j; int i,j;
for (j=1; j<h; j++) for (j=0; j<h; j++)
for (i=1; i<w; i++) for (i=0; i<w; i++)
blendpixel(x+i, y+j, r, g, b, a); blendpixel(x+i, y+j, r, g, b, a);
} }

View File

@@ -45,7 +45,7 @@ GameView::GameView():
v->c->OpenSearch(); v->c->OpenSearch();
} }
}; };
searchButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16)); //Open searchButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(17, 15)); //Open
searchButton->SetIcon(IconOpen); searchButton->SetIcon(IconOpen);
currentX+=18; currentX+=18;
searchButton->SetTogglable(false); searchButton->SetTogglable(false);
@@ -62,7 +62,7 @@ GameView::GameView():
v->c->ReloadSim(); v->c->ReloadSim();
} }
}; };
reloadButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16)); reloadButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(17, 15));
reloadButton->SetIcon(IconReload); reloadButton->SetIcon(IconReload);
currentX+=18; currentX+=18;
reloadButton->SetActionCallback(new ReloadAction(this)); reloadButton->SetActionCallback(new ReloadAction(this));
@@ -78,9 +78,9 @@ GameView::GameView():
v->c->OpenSaveWindow(); v->c->OpenSaveWindow();
} }
}; };
saveSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(Size.X/5, 16)); saveSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(150, 15));
saveSimulationButton->SetIcon(IconSave); saveSimulationButton->SetIcon(IconSave);
currentX+=(Size.X/5)+2; currentX+=151;
saveSimulationButton->SetActionCallback(new SaveSimulationAction(this)); saveSimulationButton->SetActionCallback(new SaveSimulationAction(this));
AddComponent(saveSimulationButton); AddComponent(saveSimulationButton);
@@ -94,9 +94,9 @@ GameView::GameView():
v->c->Vote(1); v->c->Vote(1);
} }
}; };
upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16)); upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15));
upVoteButton->SetIcon(IconVoteUp); upVoteButton->SetIcon(IconVoteUp);
currentX+=16; currentX+=15;
upVoteButton->SetActionCallback(new UpVoteAction(this)); upVoteButton->SetActionCallback(new UpVoteAction(this));
AddComponent(upVoteButton); AddComponent(upVoteButton);
@@ -110,9 +110,9 @@ GameView::GameView():
v->c->Vote(-1); v->c->Vote(-1);
} }
}; };
downVoteButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(16, 16)); downVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15));
downVoteButton->SetIcon(IconVoteDown); downVoteButton->SetIcon(IconVoteDown);
currentX+=18; currentX+=16;
downVoteButton->SetActionCallback(new DownVoteAction(this)); downVoteButton->SetActionCallback(new DownVoteAction(this));
AddComponent(downVoteButton); AddComponent(downVoteButton);
@@ -126,9 +126,9 @@ GameView::GameView():
v->c->OpenTags(); v->c->OpenTags();
} }
}; };
tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-18), ui::Point(Size.X-(currentX+176), 16)); tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(250, 15));
tagSimulationButton->SetIcon(IconTag); tagSimulationButton->SetIcon(IconTag);
currentX+=Size.X-(currentX+176); currentX+=251;
tagSimulationButton->SetActionCallback(new TagSimulationAction(this)); tagSimulationButton->SetActionCallback(new TagSimulationAction(this));
AddComponent(tagSimulationButton); AddComponent(tagSimulationButton);
@@ -142,7 +142,7 @@ GameView::GameView():
v->c->ClearSim(); v->c->ClearSim();
} }
}; };
clearSimButton = new ui::Button(ui::Point(Size.X-174, Size.Y-18), ui::Point(16, 16)); clearSimButton = new ui::Button(ui::Point(Size.X-159, Size.Y-16), ui::Point(17, 15));
clearSimButton->SetIcon(IconNew); clearSimButton->SetIcon(IconNew);
clearSimButton->SetActionCallback(new ClearSimAction(this)); clearSimButton->SetActionCallback(new ClearSimAction(this));
AddComponent(clearSimButton); AddComponent(clearSimButton);
@@ -157,7 +157,7 @@ GameView::GameView():
v->c->OpenLogin(); v->c->OpenLogin();
} }
}; };
loginButton = new ui::Button(ui::Point(Size.X-156, Size.Y-18), ui::Point(100, 16), "Login"); loginButton = new ui::Button(ui::Point(Size.X-141, Size.Y-16), ui::Point(92, 15), "Login");
loginButton->SetIcon(IconLogin); loginButton->SetIcon(IconLogin);
loginButton->SetActionCallback(new LoginAction(this)); loginButton->SetActionCallback(new LoginAction(this));
AddComponent(loginButton); AddComponent(loginButton);
@@ -172,7 +172,7 @@ GameView::GameView():
v->c->OpenOptions(); v->c->OpenOptions();
} }
}; };
simulationOptionButton = new ui::Button(ui::Point(Size.X-54, Size.Y-18), ui::Point(16, 16)); simulationOptionButton = new ui::Button(ui::Point(Size.X-48, Size.Y-16), ui::Point(15, 15));
simulationOptionButton->SetIcon(IconSimulationSettings); simulationOptionButton->SetIcon(IconSimulationSettings);
simulationOptionButton->SetActionCallback(new SimulationOptionAction(this)); simulationOptionButton->SetActionCallback(new SimulationOptionAction(this));
AddComponent(simulationOptionButton); AddComponent(simulationOptionButton);
@@ -187,7 +187,7 @@ GameView::GameView():
v->c->OpenRenderOptions(); v->c->OpenRenderOptions();
} }
}; };
displayModeButton = new ui::Button(ui::Point(Size.X-36, Size.Y-18), ui::Point(16, 16)); displayModeButton = new ui::Button(ui::Point(Size.X-32, Size.Y-16), ui::Point(15, 15));
displayModeButton->SetIcon(IconRenderSettings); displayModeButton->SetIcon(IconRenderSettings);
displayModeButton->SetActionCallback(new DisplayModeAction(this)); displayModeButton->SetActionCallback(new DisplayModeAction(this));
AddComponent(displayModeButton); AddComponent(displayModeButton);
@@ -202,7 +202,7 @@ GameView::GameView():
v->c->SetPaused(sender->GetToggleState()); v->c->SetPaused(sender->GetToggleState());
} }
}; };
pauseButton = new ui::Button(ui::Point(Size.X-18, Size.Y-18), ui::Point(16, 16)); //Pause pauseButton = new ui::Button(ui::Point(Size.X-16, Size.Y-16), ui::Point(15, 15)); //Pause
pauseButton->SetIcon(IconPause); pauseButton->SetIcon(IconPause);
pauseButton->SetTogglable(true); pauseButton->SetTogglable(true);
pauseButton->SetActionCallback(new PauseAction(this)); pauseButton->SetActionCallback(new PauseAction(this));
@@ -257,7 +257,7 @@ public:
void GameView::NotifyMenuListChanged(GameModel * sender) void GameView::NotifyMenuListChanged(GameModel * sender)
{ {
int currentY = YRES+MENUSIZE-18-(sender->GetMenuList().size()*18); int currentY = YRES+MENUSIZE-16-(sender->GetMenuList().size()*16);
for(int i = 0; i < menuButtons.size(); i++) for(int i = 0; i < menuButtons.size(); i++)
{ {
RemoveComponent(menuButtons[i]); RemoveComponent(menuButtons[i]);
@@ -275,10 +275,10 @@ void GameView::NotifyMenuListChanged(GameModel * sender)
{ {
std::string tempString = ""; std::string tempString = "";
tempString += menuList[i]->GetIcon(); tempString += menuList[i]->GetIcon();
ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-18, currentY), ui::Point(16, 16), tempString); ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-16, currentY), ui::Point(15, 15), tempString);
tempButton->SetTogglable(true); tempButton->SetTogglable(true);
tempButton->SetActionCallback(new MenuAction(this, menuList[i])); tempButton->SetActionCallback(new MenuAction(this, menuList[i]));
currentY+=18; currentY+=16;
AddComponent(tempButton); AddComponent(tempButton);
menuButtons.push_back(tempButton); menuButtons.push_back(tempButton);
} }
@@ -344,9 +344,9 @@ void GameView::NotifyToolListChanged(GameModel * sender)
for(int i = 0; i < toolList.size(); i++) for(int i = 0; i < toolList.size(); i++)
{ {
//ToolButton * tempButton = new ToolButton(ui::Point(XRES+1, currentY), ui::Point(28, 15), toolList[i]->GetName()); //ToolButton * tempButton = new ToolButton(ui::Point(XRES+1, currentY), ui::Point(28, 15), toolList[i]->GetName());
ToolButton * tempButton = new ToolButton(ui::Point(currentX, YRES+1), ui::Point(28, 15), toolList[i]->GetName()); ToolButton * tempButton = new ToolButton(ui::Point(currentX, YRES+1), ui::Point(30, 18), toolList[i]->GetName());
//currentY -= 17; //currentY -= 17;
currentX -= 32; currentX -= 31;
tempButton->SetActionCallback(new ToolAction(this, toolList[i])); tempButton->SetActionCallback(new ToolAction(this, toolList[i]));
tempButton->SetBackgroundColour(ui::Colour(toolList[i]->colRed, toolList[i]->colGreen, toolList[i]->colBlue)); tempButton->SetBackgroundColour(ui::Colour(toolList[i]->colRed, toolList[i]->colGreen, toolList[i]->colBlue));
@@ -364,7 +364,7 @@ void GameView::NotifyToolListChanged(GameModel * sender)
tempButton->SetSelectionState(2); //Tertiary tempButton->SetSelectionState(2); //Tertiary
} }
tempButton->SetAlignment(AlignCentre, AlignBottom); tempButton->SetAlignment(AlignCentre, AlignMiddle);
AddComponent(tempButton); AddComponent(tempButton);
toolButtons.push_back(tempButton); toolButtons.push_back(tempButton);
} }

View File

@@ -12,6 +12,7 @@ ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_):
ui::Button(position, size, text_) ui::Button(position, size, text_)
{ {
SetSelectionState(-1); SetSelectionState(-1);
activeBorder = ui::Colour(255, 0, 0);
} }
void ToolButton::OnMouseClick(int x, int y, unsigned int button) void ToolButton::OnMouseClick(int x, int y, unsigned int button)
@@ -37,9 +38,18 @@ void ToolButton::OnMouseUp(int x, int y, unsigned int button)
void ToolButton::Draw(const ui::Point& screenPos) void ToolButton::Draw(const ui::Point& screenPos)
{ {
Graphics * g = ui::Engine::Ref().g; Graphics * g = ui::Engine::Ref().g;
int totalColour = background.Red + 3*background.Green + 2*background.Blue; int totalColour = background.Red + (3*background.Green) + (2*background.Blue);
g->fillrect(screenPos.X, screenPos.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 255); g->fillrect(screenPos.X+2, screenPos.Y+2, Size.X-4, Size.Y-4, background.Red, background.Green, background.Blue, background.Alpha);
if(isMouseInside && currentSelection == -1)
{
g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, activeBorder.Red, activeBorder.Green, activeBorder.Blue, activeBorder.Alpha);
}
else
{
g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, border.Alpha);
}
if (totalColour<544) if (totalColour<544)
{ {
@@ -49,12 +59,6 @@ void ToolButton::Draw(const ui::Point& screenPos)
{ {
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, buttonDisplayText.c_str(), 0, 0, 0, 255); g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, buttonDisplayText.c_str(), 0, 0, 0, 255);
} }
if(currentSelection!=-1)
{
//g->fillrect(screenPos.X+1, screenPos.Y+1, Size.X-2, Size.Y-2, 255, 255, 255, 170);
g->fillrect(screenPos.X+2, screenPos.Y+2, Size.Y-4, Size.Y-4, 0, 0, 0, 170);
g->drawtext(screenPos.X+5, screenPos.Y+4, selectionText, 255, 255, 255, 255);
}
} }
void ToolButton::SetSelectionState(int state) void ToolButton::SetSelectionState(int state)
@@ -63,16 +67,16 @@ void ToolButton::SetSelectionState(int state)
switch(state) switch(state)
{ {
case 0: case 0:
selectionText = "L"; border = ui::Colour(255, 0, 0);
break; break;
case 1: case 1:
selectionText = "R"; border = ui::Colour(0, 0, 255);
break; break;
case 2: case 2:
selectionText = "M"; border = ui::Colour(0, 255, 0);
break; break;
default: default:
selectionText = ""; border = ui::Colour(0, 0, 0);
break; break;
} }
} }

View File

@@ -12,7 +12,6 @@
class ToolButton: public ui::Button { class ToolButton: public ui::Button {
int currentSelection; int currentSelection;
std::string selectionText;
public: public:
ToolButton(ui::Point position, ui::Point size, std::string text_); ToolButton(ui::Point position, ui::Point size, std::string text_);
virtual void OnMouseUp(int x, int y, unsigned int button); virtual void OnMouseUp(int x, int y, unsigned int button);

View File

@@ -45,6 +45,8 @@ void Button::TextPosition()
buttonDisplayText += "..."; buttonDisplayText += "...";
} }
} }
// Values 3 and 10 are for vertical padding of 3 pixels, middle uses 7 as that's the height of a capital
switch(textVAlign) switch(textVAlign)
{ {
case AlignTop: case AlignTop:
@@ -54,7 +56,7 @@ void Button::TextPosition()
textPosition.Y = (Size.Y-10)/2; textPosition.Y = (Size.Y-10)/2;
break; break;
case AlignBottom: case AlignBottom:
textPosition.Y = Size.Y-12; textPosition.Y = Size.Y-10;
break; break;
} }
@@ -131,20 +133,20 @@ void Button::Draw(const Point& screenPos)
{ {
if(isButtonDown || (isTogglable && toggle)) if(isButtonDown || (isTogglable && toggle))
{ {
g->fillrect(Position.X-1, Position.Y-1, Size.X+2, Size.Y+2, activeBackground.Red, activeBackground.Green, activeBackground.Blue, 255); g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, activeBackground.Red, activeBackground.Green, activeBackground.Blue, 255);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, activeBorder.Red, activeBorder.Green, activeBorder.Blue, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, activeBorder.Red, activeBorder.Green, activeBorder.Blue, 255);
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, activeText.Red, activeText.Green, activeText.Blue, 255); g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, activeText.Red, activeText.Green, activeText.Blue, 255);
} }
else else
{ {
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 255); g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, background.Red, background.Green, background.Blue, 255);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, 255);
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, text.Red, text.Green, text.Blue, 255); g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, text.Red, text.Green, text.Blue, 255);
} }
} }
else else
{ {
g->fillrect(Position.X, Position.Y, Size.X, Size.Y, background.Red, background.Green, background.Blue, 180); g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, background.Red, background.Green, background.Blue, 180);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 180, 180, 180, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 180, 180, 180, 255);
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, 180, 180, 180, 255); g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, 180, 180, 180, 255);
} }

View File

@@ -60,12 +60,12 @@ void Checkbox::Draw(const Point& screenPos)
Graphics * g = Engine::Ref().g; Graphics * g = Engine::Ref().g;
if(checked) if(checked)
{ {
g->fillrect(screenPos.X+4, screenPos.Y+4, 8, 8, 255, 255, 255, 255); g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 255);
} }
if(isMouseOver) if(isMouseOver)
{ {
g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 255); g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 255);
g->fillrect(screenPos.X+4, screenPos.Y+4, 8, 8, 255, 255, 255, 170); g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 170);
g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 255); g->drawtext(screenPos.X+18, screenPos.Y+4, text, 255, 255, 255, 255);
} }
else else

View File

@@ -37,6 +37,17 @@ SaveButton::SaveButton(Point position, Point size, Save * save):
voteColour.Red = (1.0f-voteRatio)*255; voteColour.Red = (1.0f-voteRatio)*255;
voteColour.Green = voteRatio*255; voteColour.Green = voteRatio*255;
} }
if(save)
{
name = save->name;
if(Graphics::textwidth((char *)name.c_str()) > Size.X)
{
int position = Graphics::textwidthx((char *)name.c_str(), Size.X - 22);
name = name.erase(position, name.length()-position);
name += "...";
}
}
} }
SaveButton::~SaveButton() SaveButton::~SaveButton()
@@ -122,10 +133,10 @@ void SaveButton::Draw(const Point& screenPos)
g->drawrect(screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 210, 230, 255, 255); g->drawrect(screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 210, 230, 255, 255);
else else
g->drawrect(screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 180, 180, 180, 255); g->drawrect(screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 180, 180, 180, 255);
g->drawrect(screenPos.X-3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, 6, thumbBoxSize.Y, 180, 180, 180, 255); g->drawrect(screenPos.X-4+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, 7, thumbBoxSize.Y, 180, 180, 180, 255);
int voteBar = max(10.0f, ((float)(thumbBoxSize.Y-2))*voteRatio); int voteBar = max(10.0f, ((float)(thumbBoxSize.Y-4))*voteRatio);
g->fillrect(1+screenPos.X-3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, 1+(screenPos.Y-2)+(thumbBoxSize.Y-voteBar)+(Size.Y-21-thumbBoxSize.Y)/2, 4, voteBar, voteColour.Red, voteColour.Green, voteColour.Blue, 255); g->fillrect(1+screenPos.X-3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, (screenPos.Y-2)+(thumbBoxSize.Y-voteBar)+(Size.Y-21-thumbBoxSize.Y)/2, 3, voteBar, voteColour.Red, voteColour.Green, voteColour.Blue, 255);
} }
else else
{ {
@@ -138,12 +149,12 @@ void SaveButton::Draw(const Point& screenPos)
if(isMouseInside) if(isMouseInside)
{ {
//g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255); //g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255);
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->name.c_str()))/2, screenPos.Y+Size.Y - 21, save->name, 255, 255, 255, 255); g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)name.c_str()))/2, screenPos.Y+Size.Y - 21, name, 255, 255, 255, 255);
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 200, 230, 255, 255); g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 200, 230, 255, 255);
} }
else else
{ {
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->name.c_str()))/2, screenPos.Y+Size.Y - 21, save->name, 180, 180, 180, 255); g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)name.c_str()))/2, screenPos.Y+Size.Y - 21, name, 180, 180, 180, 255);
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 100, 130, 160, 255); g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 100, 130, 160, 255);
} }
} }

View File

@@ -24,6 +24,7 @@ class SaveButton : public Component
{ {
Save * save; Save * save;
Thumbnail * thumbnail; Thumbnail * thumbnail;
std::string name;
public: public:
SaveButton(Point position, Point size, Save * save); SaveButton(Point position, Point size, Save * save);
virtual ~SaveButton(); virtual ~SaveButton();

View File

@@ -27,7 +27,7 @@ PreviewView::PreviewView():
v->c->Exit(); v->c->Exit();
} }
}; };
openButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(50, 16), "Open"); openButton = new ui::Button(ui::Point(0, Size.Y-19), ui::Point(51, 19), "Open");
openButton->SetAlignment(AlignLeft, AlignMiddle); openButton->SetAlignment(AlignLeft, AlignMiddle);
openButton->SetIcon(IconOpen); openButton->SetIcon(IconOpen);
openButton->SetActionCallback(new OpenAction(this)); openButton->SetActionCallback(new OpenAction(this));
@@ -44,7 +44,7 @@ PreviewView::PreviewView():
} }
}; };
favButton = new ui::Button(ui::Point(50, Size.Y-16), ui::Point(50, 16), "Fav."); favButton = new ui::Button(ui::Point(51, Size.Y-19), ui::Point(51, 19), "Fav.");
favButton->SetAlignment(AlignLeft, AlignMiddle); favButton->SetAlignment(AlignLeft, AlignMiddle);
favButton->SetIcon(IconFavourite); favButton->SetIcon(IconFavourite);
favButton->SetActionCallback(new FavAction(this)); favButton->SetActionCallback(new FavAction(this));
@@ -71,7 +71,7 @@ PreviewView::PreviewView():
new TextPrompt("Report Save", "Reason for reporting", true, new ReportPromptCallback(v)); new TextPrompt("Report Save", "Reason for reporting", true, new ReportPromptCallback(v));
} }
}; };
reportButton = new ui::Button(ui::Point(100, Size.Y-16), ui::Point(50, 16), "Report"); reportButton = new ui::Button(ui::Point(102, Size.Y-19), ui::Point(51, 19), "Report");
reportButton->SetAlignment(AlignLeft, AlignMiddle); reportButton->SetAlignment(AlignLeft, AlignMiddle);
reportButton->SetIcon(IconReport); reportButton->SetIcon(IconReport);
reportButton->SetActionCallback(new ReportAction(this)); reportButton->SetActionCallback(new ReportAction(this));
@@ -88,7 +88,7 @@ PreviewView::PreviewView():
} }
}; };
browserOpenButton = new ui::Button(ui::Point((XRES/2)-110, Size.Y-16), ui::Point(110, 16), "Open in browser"); browserOpenButton = new ui::Button(ui::Point((XRES/2)-108, Size.Y-19), ui::Point(108, 19), "Open in browser");
browserOpenButton->SetAlignment(AlignLeft, AlignMiddle); browserOpenButton->SetAlignment(AlignLeft, AlignMiddle);
browserOpenButton->SetIcon(IconOpen); browserOpenButton->SetIcon(IconOpen);
browserOpenButton->SetActionCallback(new BrowserOpenAction(this)); browserOpenButton->SetActionCallback(new BrowserOpenAction(this));