by date turns white like my own does when selected

This commit is contained in:
jacob1
2013-03-04 15:27:51 -05:00
parent 0f5b4a9ec8
commit 38573cc30e
3 changed files with 226 additions and 223 deletions

View File

@@ -42,7 +42,7 @@ GameModel::GameModel():
std::fill(decoToolset, decoToolset+3, (Tool*)NULL); std::fill(decoToolset, decoToolset+3, (Tool*)NULL);
std::fill(regularToolset, regularToolset+3, (Tool*)NULL); std::fill(regularToolset, regularToolset+3, (Tool*)NULL);
//Default render prefs //Default render prefs
std::vector<unsigned int> tempArray; std::vector<unsigned int> tempArray;
tempArray.push_back(RENDER_FIRE); tempArray.push_back(RENDER_FIRE);
tempArray.push_back(RENDER_EFFE); tempArray.push_back(RENDER_EFFE);

View File

@@ -52,14 +52,14 @@ public:
void SetSplitActionCallback(SplitButtonAction * newAction) { splitActionCallback = newAction; } void SetSplitActionCallback(SplitButtonAction * newAction) { splitActionCallback = newAction; }
virtual void OnMouseUnclick(int x, int y, unsigned int button) virtual void OnMouseUnclick(int x, int y, unsigned int button)
{ {
if(isButtonDown) if(isButtonDown)
{ {
if(leftDown) if(leftDown)
DoLeftAction(); DoLeftAction();
else if(rightDown) else if(rightDown)
DoRightAction(); DoRightAction();
} }
ui::Button::OnMouseUnclick(x, y, button); ui::Button::OnMouseUnclick(x, y, button);
} }
virtual void OnMouseMovedInside(int x, int y, int dx, int dy) virtual void OnMouseMovedInside(int x, int y, int dx, int dy)
@@ -81,7 +81,7 @@ public:
} }
virtual void OnMouseEnter(int x, int y) virtual void OnMouseEnter(int x, int y)
{ {
isMouseInside = true; isMouseInside = true;
if(!Enabled) if(!Enabled)
return; return;
if(x >= splitPosition || !showSplit) if(x >= splitPosition || !showSplit)
@@ -218,170 +218,170 @@ GameView::GameView():
searchButton->SetActionCallback(new SearchAction(this)); searchButton->SetActionCallback(new SearchAction(this));
AddComponent(searchButton); AddComponent(searchButton);
class ReloadAction : public ui::ButtonAction class ReloadAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
public: public:
ReloadAction(GameView * _v) { v = _v; } ReloadAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
v->c->ReloadSim(); v->c->ReloadSim();
} }
void AltActionCallback(ui::Button * sender) void AltActionCallback(ui::Button * sender)
{ {
v->c->OpenSavePreview(); v->c->OpenSavePreview();
} }
}; };
reloadButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(17, 15), "", "Reload the simulation"); reloadButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(17, 15), "", "Reload the simulation");
reloadButton->SetIcon(IconReload); reloadButton->SetIcon(IconReload);
reloadButton->Appearance.Margin.Left+=2; reloadButton->Appearance.Margin.Left+=2;
currentX+=18; currentX+=18;
reloadButton->SetActionCallback(new ReloadAction(this)); reloadButton->SetActionCallback(new ReloadAction(this));
AddComponent(reloadButton); AddComponent(reloadButton);
class SaveSimulationAction : public SplitButtonAction class SaveSimulationAction : public SplitButtonAction
{ {
GameView * v; GameView * v;
public: public:
SaveSimulationAction(GameView * _v) { v = _v; } SaveSimulationAction(GameView * _v) { v = _v; }
void ActionCallbackRight(ui::Button * sender) void ActionCallbackRight(ui::Button * sender)
{ {
if(v->CtrlBehaviour()) if(v->CtrlBehaviour())
v->c->OpenLocalSaveWindow(false); v->c->OpenLocalSaveWindow(false);
else else
v->c->OpenSaveWindow(); v->c->OpenSaveWindow();
} }
void ActionCallbackLeft(ui::Button * sender) void ActionCallbackLeft(ui::Button * sender)
{ {
if(v->CtrlBehaviour()) if(v->CtrlBehaviour())
v->c->OpenLocalSaveWindow(true); v->c->OpenLocalSaveWindow(true);
else else
v->c->SaveAsCurrent(); v->c->SaveAsCurrent();
} }
}; };
saveSimulationButton = new SplitButton(ui::Point(currentX, Size.Y-16), ui::Point(150, 15), "[untitled simulation]", "Save game as current name", "Save game as new name", 19); saveSimulationButton = new SplitButton(ui::Point(currentX, Size.Y-16), ui::Point(150, 15), "[untitled simulation]", "Save game as current name", "Save game as new name", 19);
saveSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; saveSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
saveSimulationButton->SetIcon(IconSave); saveSimulationButton->SetIcon(IconSave);
currentX+=151; currentX+=151;
((SplitButton*)saveSimulationButton)->SetSplitActionCallback(new SaveSimulationAction(this)); ((SplitButton*)saveSimulationButton)->SetSplitActionCallback(new SaveSimulationAction(this));
AddComponent(saveSimulationButton); AddComponent(saveSimulationButton);
class UpVoteAction : public ui::ButtonAction class UpVoteAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
public: public:
UpVoteAction(GameView * _v) { v = _v; } UpVoteAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
v->c->Vote(1); v->c->Vote(1);
} }
}; };
upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15), "", "Like this save"); upVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15), "", "Like this save");
upVoteButton->SetIcon(IconVoteUp); upVoteButton->SetIcon(IconVoteUp);
upVoteButton->Appearance.Margin.Top+=2; upVoteButton->Appearance.Margin.Top+=2;
upVoteButton->Appearance.Margin.Left+=2; upVoteButton->Appearance.Margin.Left+=2;
currentX+=14; currentX+=14;
upVoteButton->SetActionCallback(new UpVoteAction(this)); upVoteButton->SetActionCallback(new UpVoteAction(this));
AddComponent(upVoteButton); AddComponent(upVoteButton);
class DownVoteAction : public ui::ButtonAction class DownVoteAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
public: public:
DownVoteAction(GameView * _v) { v = _v; } DownVoteAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
v->c->Vote(-1); v->c->Vote(-1);
} }
}; };
downVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15), "", "Dislike this save"); downVoteButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(15, 15), "", "Dislike this save");
downVoteButton->SetIcon(IconVoteDown); downVoteButton->SetIcon(IconVoteDown);
downVoteButton->Appearance.Margin.Bottom+=2; downVoteButton->Appearance.Margin.Bottom+=2;
downVoteButton->Appearance.Margin.Left+=2; downVoteButton->Appearance.Margin.Left+=2;
currentX+=16; currentX+=16;
downVoteButton->SetActionCallback(new DownVoteAction(this)); downVoteButton->SetActionCallback(new DownVoteAction(this));
AddComponent(downVoteButton); AddComponent(downVoteButton);
class TagSimulationAction : public ui::ButtonAction class TagSimulationAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
public: public:
TagSimulationAction(GameView * _v) { v = _v; } TagSimulationAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
v->c->OpenTags(); v->c->OpenTags();
} }
}; };
tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(251, 15), "[no tags set]", "Add simulation tags"); tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(251, 15), "[no tags set]", "Add simulation tags");
tagSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tagSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tagSimulationButton->SetIcon(IconTag); tagSimulationButton->SetIcon(IconTag);
currentX+=252; currentX+=252;
tagSimulationButton->SetActionCallback(new TagSimulationAction(this)); tagSimulationButton->SetActionCallback(new TagSimulationAction(this));
AddComponent(tagSimulationButton); AddComponent(tagSimulationButton);
class ClearSimAction : public ui::ButtonAction class ClearSimAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
public: public:
ClearSimAction(GameView * _v) { v = _v; } ClearSimAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
v->c->ClearSim(); v->c->ClearSim();
} }
}; };
clearSimButton = new ui::Button(ui::Point(Size.X-159, Size.Y-16), ui::Point(17, 15), "", "Erase everything"); clearSimButton = new ui::Button(ui::Point(Size.X-159, Size.Y-16), ui::Point(17, 15), "", "Erase everything");
clearSimButton->SetIcon(IconNew); clearSimButton->SetIcon(IconNew);
clearSimButton->Appearance.Margin.Left+=2; clearSimButton->Appearance.Margin.Left+=2;
clearSimButton->SetActionCallback(new ClearSimAction(this)); clearSimButton->SetActionCallback(new ClearSimAction(this));
AddComponent(clearSimButton); AddComponent(clearSimButton);
class LoginAction : public ui::ButtonAction class LoginAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
public: public:
LoginAction(GameView * _v) { v = _v; } LoginAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
v->c->OpenLogin(); v->c->OpenLogin();
} }
}; };
loginButton = new ui::Button(ui::Point(Size.X-141, Size.Y-16), ui::Point(92, 15), "[sign in]", "Sign into simulation server"); loginButton = new ui::Button(ui::Point(Size.X-141, Size.Y-16), ui::Point(92, 15), "[sign in]", "Sign into simulation server");
loginButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; loginButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
loginButton->SetIcon(IconLogin); loginButton->SetIcon(IconLogin);
loginButton->SetActionCallback(new LoginAction(this)); loginButton->SetActionCallback(new LoginAction(this));
AddComponent(loginButton); AddComponent(loginButton);
class SimulationOptionAction : public ui::ButtonAction class SimulationOptionAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
public: public:
SimulationOptionAction(GameView * _v) { v = _v; } SimulationOptionAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
v->c->OpenOptions(); v->c->OpenOptions();
} }
}; };
simulationOptionButton = new ui::Button(ui::Point(Size.X-48, Size.Y-16), ui::Point(15, 15), "", "Simulation options"); simulationOptionButton = new ui::Button(ui::Point(Size.X-48, Size.Y-16), ui::Point(15, 15), "", "Simulation options");
simulationOptionButton->SetIcon(IconSimulationSettings); simulationOptionButton->SetIcon(IconSimulationSettings);
simulationOptionButton->Appearance.Margin.Left+=2; simulationOptionButton->Appearance.Margin.Left+=2;
simulationOptionButton->SetActionCallback(new SimulationOptionAction(this)); simulationOptionButton->SetActionCallback(new SimulationOptionAction(this));
AddComponent(simulationOptionButton); AddComponent(simulationOptionButton);
class DisplayModeAction : public ui::ButtonAction class DisplayModeAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
public: public:
DisplayModeAction(GameView * _v) { v = _v; } DisplayModeAction(GameView * _v) { v = _v; }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
v->c->OpenRenderOptions(); v->c->OpenRenderOptions();
} }
}; };
displayModeButton = new ui::Button(ui::Point(Size.X-32, Size.Y-16), ui::Point(15, 15), "", "Renderer options"); displayModeButton = new ui::Button(ui::Point(Size.X-32, Size.Y-16), ui::Point(15, 15), "", "Renderer options");
displayModeButton->SetIcon(IconRenderSettings); displayModeButton->SetIcon(IconRenderSettings);
displayModeButton->Appearance.Margin.Left+=2; displayModeButton->Appearance.Margin.Left+=2;
displayModeButton->SetActionCallback(new DisplayModeAction(this)); displayModeButton->SetActionCallback(new DisplayModeAction(this));
AddComponent(displayModeButton); AddComponent(displayModeButton);
class PauseAction : public ui::ButtonAction class PauseAction : public ui::ButtonAction
{ {
@@ -1609,33 +1609,33 @@ void GameView::DoDraw()
void GameView::NotifyNotificationsChanged(GameModel * sender) void GameView::NotifyNotificationsChanged(GameModel * sender)
{ {
class NotificationButtonAction : public ui::ButtonAction class NotificationButtonAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
Notification * notification; Notification * notification;
public: public:
NotificationButtonAction(GameView * v, Notification * notification) : v(v), notification(notification) { } NotificationButtonAction(GameView * v, Notification * notification) : v(v), notification(notification) { }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
notification->Action(); notification->Action();
//v->c->RemoveNotification(notification); //v->c->RemoveNotification(notification);
} }
}; };
class CloseNotificationButtonAction : public ui::ButtonAction class CloseNotificationButtonAction : public ui::ButtonAction
{ {
GameView * v; GameView * v;
Notification * notification; Notification * notification;
public: public:
CloseNotificationButtonAction(GameView * v, Notification * notification) : v(v), notification(notification) { } CloseNotificationButtonAction(GameView * v, Notification * notification) : v(v), notification(notification) { }
void ActionCallback(ui::Button * sender) void ActionCallback(ui::Button * sender)
{ {
v->c->RemoveNotification(notification); v->c->RemoveNotification(notification);
} }
void AltActionCallback(ui::Button * sender) void AltActionCallback(ui::Button * sender)
{ {
v->c->RemoveNotification(notification); v->c->RemoveNotification(notification);
} }
}; };
for(std::vector<ui::Component*>::const_iterator iter = notificationComponents.begin(), end = notificationComponents.end(); iter != end; ++iter) { for(std::vector<ui::Component*>::const_iterator iter = notificationComponents.begin(), end = notificationComponents.end(); iter != end; ++iter) {
ui::Component * cNotification = *iter; ui::Component * cNotification = *iter;
@@ -1942,7 +1942,7 @@ void GameView::OnDraw()
{ {
string message = (*iter); string message = (*iter);
startY -= 13; startY -= 13;
g->fillrect(startX-3, startY-3, Graphics::textwidth((char*)message.c_str())+6 , 14, 0, 0, 0, 100); g->fillrect(startX-3, startY-3, Graphics::textwidth((char*)message.c_str())+6 , 14, 0, 0, 0, 100);
g->drawtext(startX, startY, message.c_str(), 255, 255, 255, startAlpha); g->drawtext(startX, startY, message.c_str(), 255, 255, 255, startAlpha);
startAlpha-=14; startAlpha-=14;
} }

View File

@@ -53,6 +53,7 @@ SearchView::SearchView():
}; };
sortButton = new ui::Button(ui::Point(XRES+BARSIZE-140, 10), ui::Point(61, 17), "Sort"); sortButton = new ui::Button(ui::Point(XRES+BARSIZE-140, 10), ui::Point(61, 17), "Sort");
sortButton->SetIcon(IconVoteSort); sortButton->SetIcon(IconVoteSort);
sortButton->SetTogglable(true);
sortButton->SetActionCallback(new SortAction(this)); sortButton->SetActionCallback(new SortAction(this));
sortButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; sortButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
sortButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; sortButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
@@ -274,54 +275,56 @@ void SearchView::NotifySortChanged(SearchModel * sender)
{ {
if(sender->GetSort() == "best") if(sender->GetSort() == "best")
{ {
sortButton->SetText("By votes"); sortButton->SetToggleState(false);
sortButton->SetIcon(IconVoteSort); sortButton->SetText("By votes");
sortButton->SetIcon(IconVoteSort);
} }
else else
{ {
sortButton->SetText("By date"); sortButton->SetToggleState(true);
sortButton->SetText("By date");
sortButton->SetIcon(IconDateSort); sortButton->SetIcon(IconDateSort);
} }
} }
void SearchView::NotifyShowOwnChanged(SearchModel * sender) void SearchView::NotifyShowOwnChanged(SearchModel * sender)
{ {
ownButton->SetToggleState(sender->GetShowOwn()); ownButton->SetToggleState(sender->GetShowOwn());
if(sender->GetShowOwn() || Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator) if(sender->GetShowOwn() || Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator)
{ {
unpublishSelected->Enabled = true; unpublishSelected->Enabled = true;
removeSelected->Enabled = true; removeSelected->Enabled = true;
} }
else if(sender->GetShowFavourite()) else if(sender->GetShowFavourite())
{ {
unpublishSelected->Enabled = false; unpublishSelected->Enabled = false;
removeSelected->Enabled = false; removeSelected->Enabled = false;
} }
else else
{ {
unpublishSelected->Enabled = false; unpublishSelected->Enabled = false;
removeSelected->Enabled = false; removeSelected->Enabled = false;
} }
} }
void SearchView::NotifyShowFavouriteChanged(SearchModel * sender) void SearchView::NotifyShowFavouriteChanged(SearchModel * sender)
{ {
favButton->SetToggleState(sender->GetShowFavourite()); favButton->SetToggleState(sender->GetShowFavourite());
if(sender->GetShowFavourite()) if(sender->GetShowFavourite())
{ {
unpublishSelected->Enabled = false; unpublishSelected->Enabled = false;
removeSelected->Enabled = false; removeSelected->Enabled = false;
} }
else if(sender->GetShowOwn() || Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator) else if(sender->GetShowOwn() || Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator)
{ {
unpublishSelected->Enabled = true; unpublishSelected->Enabled = true;
removeSelected->Enabled = true; removeSelected->Enabled = true;
} }
else else
{ {
unpublishSelected->Enabled = false; unpublishSelected->Enabled = false;
removeSelected->Enabled = false; removeSelected->Enabled = false;
} }
} }
void SearchView::NotifyPageChanged(SearchModel * sender) void SearchView::NotifyPageChanged(SearchModel * sender)