summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-05-15 17:13:17 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-05-15 17:13:17 (GMT)
commit136675b56a8a1862afb41ccee5c14e93e483b964 (patch)
tree8f679477c5e1c0984a5cb9c169e339c1ca0d6e0c /src/game
parent45563e97e813cfd21724ad1111e5de3e04679e1a (diff)
downloadpowder-136675b56a8a1862afb41ccee5c14e93e483b964.zip
powder-136675b56a8a1862afb41ccee5c14e93e483b964.tar.gz
Move style into Component
Diffstat (limited to 'src/game')
-rw-r--r--src/game/GameModel.cpp1
-rw-r--r--src/game/GameView.cpp21
-rw-r--r--src/game/PropertyTool.cpp8
-rw-r--r--src/game/SignTool.cpp8
-rw-r--r--src/game/ToolButton.cpp18
5 files changed, 30 insertions, 26 deletions
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp
index 60e3c15..ae3b191 100644
--- a/src/game/GameModel.cpp
+++ b/src/game/GameModel.cpp
@@ -125,7 +125,6 @@ GameModel::GameModel():
toolList = menuList[SC_POWDERS]->GetToolList();
//Load last user
- std::cout << Client::Ref().GetAuthUser().Username << std::endl;
if(Client::Ref().GetAuthUser().ID)
{
currentUser = Client::Ref().GetAuthUser();
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index c05ca12..1e4ca76 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -79,6 +79,7 @@ GameView::GameView():
}
};
saveSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(150, 15));
+ saveSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
saveSimulationButton->SetIcon(IconSave);
currentX+=151;
saveSimulationButton->SetActionCallback(new SaveSimulationAction(this));
@@ -127,6 +128,7 @@ GameView::GameView():
}
};
tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(250, 15));
+ tagSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tagSimulationButton->SetIcon(IconTag);
currentX+=251;
tagSimulationButton->SetActionCallback(new TagSimulationAction(this));
@@ -158,6 +160,7 @@ GameView::GameView():
}
};
loginButton = new ui::Button(ui::Point(Size.X-141, Size.Y-16), ui::Point(92, 15), "Login");
+ loginButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
loginButton->SetIcon(IconLogin);
loginButton->SetActionCallback(new LoginAction(this));
AddComponent(loginButton);
@@ -276,6 +279,7 @@ void GameView::NotifyMenuListChanged(GameModel * sender)
std::string tempString = "";
tempString += menuList[i]->GetIcon();
ui::Button * tempButton = new ui::Button(ui::Point(XRES+BARSIZE-16, currentY), ui::Point(15, 15), tempString);
+ tempButton->Appearance.Margin = ui::Border(0, 2, 3, 2);
tempButton->SetTogglable(true);
tempButton->SetActionCallback(new MenuAction(this, menuList[i]));
currentY+=16;
@@ -349,7 +353,7 @@ void GameView::NotifyToolListChanged(GameModel * sender)
currentX -= 31;
tempButton->SetActionCallback(new ToolAction(this, toolList[i]));
- tempButton->SetBackgroundColour(ui::Colour(toolList[i]->colRed, toolList[i]->colGreen, toolList[i]->colBlue));
+ tempButton->Appearance.BackgroundInactive = ui::Colour(toolList[i]->colRed, toolList[i]->colGreen, toolList[i]->colBlue);
if(sender->GetActiveTool(0) == toolList[i])
{
@@ -364,7 +368,8 @@ void GameView::NotifyToolListChanged(GameModel * sender)
tempButton->SetSelectionState(2); //Tertiary
}
- tempButton->SetAlignment(AlignCentre, AlignMiddle);
+ tempButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
+ tempButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(tempButton);
toolButtons.push_back(tempButton);
}
@@ -439,14 +444,14 @@ void GameView::NotifySaveChanged(GameModel * sender)
reloadButton->Enabled = true;
upVoteButton->Enabled = (sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==0);
if(sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==1)
- upVoteButton->SetBackgroundColour(ui::Colour(0, 200, 40));
+ upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 200, 40));
else
- upVoteButton->SetBackgroundColour(ui::Colour(0, 0, 0));
+ upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0));
downVoteButton->Enabled = upVoteButton->Enabled;
if(sender->GetSave()->GetID() && sender->GetUser().ID && sender->GetSave()->GetVote()==-1)
- downVoteButton->SetBackgroundColour(ui::Colour(200, 40, 40));
+ downVoteButton->Appearance.BackgroundInactive = (ui::Colour(200, 40, 40));
else
- downVoteButton->SetBackgroundColour(ui::Colour(0, 0, 0));
+ downVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0));
tagSimulationButton->Enabled = (sender->GetSave()->GetID() && sender->GetUser().ID);
if(sender->GetSave()->GetID())
{
@@ -466,9 +471,9 @@ void GameView::NotifySaveChanged(GameModel * sender)
saveSimulationButton->SetText("");
reloadButton->Enabled = false;
upVoteButton->Enabled = false;
- upVoteButton->SetBackgroundColour(ui::Colour(0, 0, 0));
+ upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0));
downVoteButton->Enabled = false;
- upVoteButton->SetBackgroundColour(ui::Colour(0, 0, 0));
+ upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0));
tagSimulationButton->Enabled = false;
tagSimulationButton->SetText("");
}
diff --git a/src/game/PropertyTool.cpp b/src/game/PropertyTool.cpp
index ccc7a8d..bddce44 100644
--- a/src/game/PropertyTool.cpp
+++ b/src/game/PropertyTool.cpp
@@ -49,12 +49,12 @@ position(position_)
ui::Label * messageLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Edit property");
messageLabel->SetTextColour(style::Colour::InformationTitle);
- messageLabel->SetAlignment(AlignLeft, AlignTop);
+ messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
AddComponent(messageLabel);
ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 17), "OK");
- okayButton->SetAlignment(AlignLeft, AlignBottom);
- okayButton->SetBorderColour(ui::Colour(200, 200, 200));
+ okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; okayButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
+ okayButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);
okayButton->SetActionCallback(new OkayAction(this));
AddComponent(okayButton);
@@ -67,7 +67,7 @@ position(position_)
property->SetOption(0);
textField = new ui::Textbox(ui::Point(8, 46), ui::Point(Size.X-16, 16), "");
- textField->SetAlignment(AlignLeft, AlignBottom);
+ textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; textField->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
AddComponent(textField);
ui::Engine::Ref().ShowWindow(this);
diff --git a/src/game/SignTool.cpp b/src/game/SignTool.cpp
index 2d7a6e5..a01ba77 100644
--- a/src/game/SignTool.cpp
+++ b/src/game/SignTool.cpp
@@ -50,12 +50,12 @@ SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Poi
{
ui::Label * messageLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "New sign");
messageLabel->SetTextColour(style::Colour::InformationTitle);
- messageLabel->SetAlignment(AlignLeft, AlignTop);
+ messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
AddComponent(messageLabel);
ui::Button * okayButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "OK");
- okayButton->SetAlignment(AlignLeft, AlignBottom);
- okayButton->SetBorderColour(ui::Colour(200, 200, 200));
+ okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; okayButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
+ okayButton->Appearance.BorderInactive = (ui::Colour(200, 200, 200));
okayButton->SetActionCallback(new OkayAction(this));
AddComponent(okayButton);
@@ -67,7 +67,7 @@ SignWindow::SignWindow(SignTool * tool_, Simulation * sim_, int signID_, ui::Poi
justification->SetOption(0);
textField = new ui::Textbox(ui::Point(8, 25), ui::Point(Size.X-16, 16), "");
- textField->SetAlignment(AlignLeft, AlignBottom);
+ textField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; textField->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
AddComponent(textField);
ui::Engine::Ref().ShowWindow(this);
diff --git a/src/game/ToolButton.cpp b/src/game/ToolButton.cpp
index 72beed7..f1c5583 100644
--- a/src/game/ToolButton.cpp
+++ b/src/game/ToolButton.cpp
@@ -12,7 +12,7 @@ ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_):
ui::Button(position, size, text_)
{
SetSelectionState(-1);
- activeBorder = ui::Colour(255, 0, 0);
+ Appearance.BorderActive = ui::Colour(255, 0, 0);
}
void ToolButton::OnMouseClick(int x, int y, unsigned int button)
@@ -38,17 +38,17 @@ void ToolButton::OnMouseUp(int x, int y, unsigned int button)
void ToolButton::Draw(const ui::Point& screenPos)
{
Graphics * g = ui::Engine::Ref().g;
- int totalColour = background.Red + (3*background.Green) + (2*background.Blue);
+ int totalColour = Appearance.BackgroundInactive.Red + (3*Appearance.BackgroundInactive.Green) + (2*Appearance.BackgroundInactive.Blue);
- g->fillrect(screenPos.X+2, screenPos.Y+2, Size.X-4, Size.Y-4, background.Red, background.Green, background.Blue, background.Alpha);
+ g->fillrect(screenPos.X+2, screenPos.Y+2, Size.X-4, Size.Y-4, Appearance.BackgroundInactive.Red, Appearance.BackgroundInactive.Green, Appearance.BackgroundInactive.Blue, Appearance.BackgroundInactive.Alpha);
if(isMouseInside && currentSelection == -1)
{
- g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, activeBorder.Red, activeBorder.Green, activeBorder.Blue, activeBorder.Alpha);
+ g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, Appearance.BorderActive.Red, Appearance.BorderActive.Green, Appearance.BorderActive.Blue, Appearance.BorderActive.Alpha);
}
else
{
- g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, border.Red, border.Green, border.Blue, border.Alpha);
+ g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, Appearance.BorderInactive.Red, Appearance.BorderInactive.Green, Appearance.BorderInactive.Blue, Appearance.BorderInactive.Alpha);
}
if (totalColour<544)
@@ -67,16 +67,16 @@ void ToolButton::SetSelectionState(int state)
switch(state)
{
case 0:
- border = ui::Colour(255, 0, 0);
+ Appearance.BorderInactive = ui::Colour(255, 0, 0);
break;
case 1:
- border = ui::Colour(0, 0, 255);
+ Appearance.BorderInactive = ui::Colour(0, 0, 255);
break;
case 2:
- border = ui::Colour(0, 255, 0);
+ Appearance.BorderInactive = ui::Colour(0, 255, 0);
break;
default:
- border = ui::Colour(0, 0, 0);
+ Appearance.BorderInactive = ui::Colour(0, 0, 0);
break;
}
}