Skip to content

Commit d30abd7

Browse files
committed
Moved more graphics values into the soft config
1 parent fb34024 commit d30abd7

File tree

3 files changed

+104
-35
lines changed

3 files changed

+104
-35
lines changed

resources/graphics.conf

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ screen.height=720
88

99
# Buttons
1010
screen.roadButton.text=Road |
11-
screen.roadButton.area=((0, 0),(0.1,0.1))
11+
screen.roadButton.area=((0,0),(0.1,0.1))
1212

1313
screen.cityButton.text=City |
1414
screen.cityButton.area=((0.1,0),(0.2,0.1))
1515

1616
screen.settlementButton.text=Settlement
17-
screen.settlementButton.area=((0.20, 0.0),(0.33, 0.1))
17+
screen.settlementButton.area=((0.20,0.0),(0.33,0.1))
1818

1919
screen.wonderButton.text=|Wonder
20-
screen.wonderButton.area=((0.55, 0.0),(0.65, 0.1))
20+
screen.wonderButton.area=((0.55,0.0),(0.65,0.1))
2121

2222
screen.endTurnButton.text=End Turn
23-
screen.endTurnButton.area=((0, 0.3),(0.1, 0.4))
23+
screen.endTurnButton.area=((0,0.3),(0.1,0.4))
2424

2525
screen.players.topY=0.82
2626
screen.players.width=0.15
@@ -30,6 +30,47 @@ screen.players.right=1.0
3030
screen.bankButton.text=Bank
3131
screen.bankButton.area=((0,0.8),(0.1,0.9))
3232

33+
screen.cancelButton.text=Cancel
34+
screen.cancelButton.area=((.92,.96),(1.0,1.0))
35+
36+
screen.developmentCardButton.text=Development Cards
37+
screen.developmentCardButton.area=((.85,.23),(1,.30))
38+
39+
screen.roadBuildingButton.text=Road Building
40+
screen.roadBuildingButton.area=((0.85,0.0),(0.97,0.05))
41+
42+
screen.knightButton.text=Knight
43+
screen.knightButton.area=((0.85,0.05),(0.97,0.10))
44+
45+
screen.yearOfPlentyButton.text=Year of Plenty
46+
screen.yearOfPlentyButton.area=((0.85,0.10),(0.97,0.15))
47+
48+
screen.monopolyButton.text=Monopoly
49+
screen.monopolyButton.area=((0.85,0.15),(0.97,0.20))
50+
51+
screen.victoryPointButton.text=Victory Point
52+
screen.victoryPointButton.area=((0.85,0.20),(0.97,0.25))
53+
54+
screen.woodButton.text=Wood
55+
screen.woodButton.area=((.85,.30),(.97,.35))
56+
57+
screen.sheepButton.text=Sheep
58+
screen.sheepButton.area=((.85,.35),(.97,.40))
59+
60+
screen.oreButton.text=Ore
61+
screen.oreButton.area=((.85,.40),(.97,.45))
62+
63+
screen.brickButton.text=Brick
64+
screen.brickButton.area=((.85,.45),(.97,.50))
65+
66+
screen.wheatButton.text=Wheat
67+
screen.wheatButton.area=((.85,.50),(.97,.55))
68+
69+
screen.showTotalButton.text=Show Totals
70+
screen.showTotalButton.area=((.85,.55),(.97,.60))
71+
72+
screen.board.area=((0,0),(1,1))
73+
3374
# Trading view screen coordinates
3475
screen.tradingView.bottomLeft=(0.1,0.1)
3576
screen.tradingView.topRight=(0.9,0.9)

src/Config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void Config::init(istream& source) {
156156
const ConfigValue& Config::operator[](const string& name) const {
157157
auto it = values.find(name);
158158
if(it == values.end()) {
159-
throw runtime_error("No such key in the config");
159+
throw runtime_error("No such key in the config: \"" + name + "\"");
160160
} else {
161161
return it->second;
162162
}

src/GameController.cpp

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,66 @@ GameController::GameController(GameBoard& model, GameView& view) : model(model),
6161
getGraphicsConfig()["screen.bankButton.area"],
6262
font, fontSize, getGraphicsConfig()["screen.bankButton.text"]));
6363

64-
view.addElement(makeViewButtonText(std::bind(&GameController::handleCancelButtonEvent, this, _1), {{.92, .96}, {1.0, 1.0}}, font, fontSize, "Cancel"));
64+
view.addElement(makeViewButtonText(
65+
std::bind(&GameController::handleCancelButtonEvent, this, _1),
66+
getGraphicsConfig()["screen.cancelButton.area"],
67+
font, fontSize, getGraphicsConfig()["screen.cancelButton.text"]));
6568

66-
view.addElement(makeViewButtonText(std::bind(&GameController::handleBuyDevelopmentCardButtonEvent, this, _1), {{.85, .23}, {1, .30}}, font, fontSize, "Development Cards"));
67-
view.addElement(makeViewButtonText(std::bind(&GameController::handleRoadCardButtonEvent, this, _1), {{0.85, 0.0}, {0.97, 0.05}}, font, fontSize, "Road Building "));
68-
view.addElement(makeViewButtonText(std::bind(&GameController::handleKnightCardButtonEvent, this, _1), {{0.85, 0.05}, {0.97, 0.10}}, font, fontSize, "Knight "));
69-
view.addElement(makeViewButtonText(std::bind(&GameController::handleYearOfPlentyCardButtonEvent, this, _1), {{0.85, 0.10}, {0.97, 0.15}}, font, fontSize, "Year of Plenty "));
70-
view.addElement(makeViewButtonText(std::bind(&GameController::handleMonopolyCardButtonEvent, this, _1), {{0.85, 0.15}, {0.97, 0.20}}, font, fontSize, "Monopoly "));
71-
view.addElement(makeViewButtonText(std::bind(&GameController::handleVictoryPointCardButtonEvent, this, _1), {{0.85, 0.20}, {0.97, 0.25}}, font, fontSize, "Victory Point "));
69+
view.addElement(makeViewButtonText(
70+
std::bind(&GameController::handleBuyDevelopmentCardButtonEvent, this, _1),
71+
getGraphicsConfig()["screen.developmentCardButton.area"],
72+
font, fontSize, getGraphicsConfig()["screen.developmentCardButton.text"]));
73+
view.addElement(makeViewButtonText(
74+
std::bind(&GameController::handleRoadCardButtonEvent, this, _1),
75+
getGraphicsConfig()["screen.roadBuildingButton.area"],
76+
font, fontSize, getGraphicsConfig()["screen.roadBuildingButton.text"]));
77+
view.addElement(makeViewButtonText(
78+
std::bind(&GameController::handleKnightCardButtonEvent, this, _1),
79+
getGraphicsConfig()["screen.knightButton.area"],
80+
font, fontSize, getGraphicsConfig()["screen.knightButton.text"]));
81+
view.addElement(makeViewButtonText(
82+
std::bind(&GameController::handleYearOfPlentyCardButtonEvent, this, _1),
83+
getGraphicsConfig()["screen.yearOfPlentyButton.area"],
84+
font, fontSize, getGraphicsConfig()["screen.yearOfPlentyButton.text"]));
85+
view.addElement(makeViewButtonText(
86+
std::bind(&GameController::handleMonopolyCardButtonEvent, this, _1),
87+
getGraphicsConfig()["screen.monopolyButton.area"],
88+
font, fontSize, getGraphicsConfig()["screen.monopolyButton.text"]));
89+
view.addElement(makeViewButtonText(
90+
std::bind(&GameController::handleVictoryPointCardButtonEvent, this, _1),
91+
getGraphicsConfig()["screen.victoryPointButton.area"],
92+
font, fontSize, getGraphicsConfig()["screen.victoryPointButton.text"]));
93+
94+
view.addElement(makeViewButtonText(
95+
std::bind(&GameController::handleWoodButtonEvent, this, _1),
96+
getGraphicsConfig()["screen.woodButton.area"],
97+
font, fontSize, getGraphicsConfig()["screen.woodButton.text"]));
98+
view.addElement(makeViewButtonText(
99+
std::bind(&GameController::handleSheepButtonEvent, this, _1),
100+
getGraphicsConfig()["screen.sheepButton.area"],
101+
font, fontSize, getGraphicsConfig()["screen.sheepButton.text"]));
102+
view.addElement(makeViewButtonText(
103+
std::bind(&GameController::handleOreButtonEvent, this, _1),
104+
getGraphicsConfig()["screen.oreButton.area"],
105+
font, fontSize, getGraphicsConfig()["screen.oreButton.text"]));
106+
view.addElement(makeViewButtonText(
107+
std::bind(&GameController::handleBrickButtonEvent, this, _1),
108+
getGraphicsConfig()["screen.brickButton.area"],
109+
font, fontSize, getGraphicsConfig()["screen.brickButton.text"]));
110+
view.addElement(makeViewButtonText(
111+
std::bind(&GameController::handleWheatButtonEvent, this, _1),
112+
getGraphicsConfig()["screen.wheatButton.area"],
113+
font, fontSize, getGraphicsConfig()["screen.wheatButton.text"]));
114+
115+
view.addElement(makeViewButtonText(
116+
std::bind(&GameController::viewCardTotals, this, _1),
117+
getGraphicsConfig()["screen.showTotalButton.area"],
118+
font, fontSize, getGraphicsConfig()["screen.showTotalButton.text"]));
119+
120+
view.addElement(100, makeViewButton(
121+
std::bind(&GameController::handleBoardEvent, this, _1),
122+
getGraphicsConfig()["screen.board.area"]));
72123

73-
view.addElement(makeViewButtonText(std::bind(&GameController::handleWoodButtonEvent, this, _1), {{.85, .30}, {.97, .35}}, font, fontSize, "Wood "));
74-
view.addElement(makeViewButtonText(std::bind(&GameController::handleSheepButtonEvent, this, _1), {{.85, .35}, {.97, .40}}, font, fontSize, "Sheep "));
75-
view.addElement(makeViewButtonText(std::bind(&GameController::handleOreButtonEvent, this, _1), {{.85, .40}, {.97, .45}}, font, fontSize, "Ore "));
76-
view.addElement(makeViewButtonText(std::bind(&GameController::handleBrickButtonEvent, this, _1), {{.85, .45}, {.97, .50}}, font, fontSize, "Brick "));
77-
view.addElement(makeViewButtonText(std::bind(&GameController::handleWheatButtonEvent, this, _1), {{.85, .50}, {.97, .55}}, font, fontSize, "Wheat "));
78-
79-
view.addElement(makeViewButtonText(std::bind(&GameController::viewCardTotals, this, _1), {{.85, .55}, {.97, .60}}, font, fontSize, "Show Totals"));
80-
81-
view.addElement(100, makeViewButton(std::bind(&GameController::handleBoardEvent, this, _1), {{0, 0}, {1, 1}}));
82124
stateStack.push_back(BASESTATE);
83125
}
84126

@@ -165,17 +207,6 @@ int GameController::getClickHistorySize(){
165207
return clickHistory.size();
166208
}
167209

168-
/**
169-
* Now that the GUI has this information implemented, I am returning before this function prints. To use this function again simply remove the return
170-
*/
171-
void printPlayerInfo(const Player& player)
172-
{
173-
return;
174-
auto color = player.getColor();
175-
std::cout << player.getName() << "'s turn. (" << std::get<0>(color) << ", " << std::get<1>(color) << ", " << std::get<2>(color) <<")" << std::endl;
176-
std::cout << "Wood: " << player.getWood() << ", Brick: " << player.getBrick() << ", Ore: " << player.getOre() << ", Wheat: " << player.getWheat() << ", Wool: " << player.getWool() << std::endl;
177-
}
178-
179210
/**
180211
* calls a function to advance turn, hide resource and development cards, check for victory, and roll dice
181212
*/
@@ -192,8 +223,6 @@ bool GameController::nextTurn(ScreenCoordinate) {
192223
view.setControlStateText("The Robber is out! Click a tile to place it!");
193224
pushState(ROBBER);
194225
}
195-
196-
printPlayerInfo(model.getCurrentPlayer());
197226
return true;
198227
}
199228

@@ -205,7 +234,6 @@ bool GameController::nextTurn(ScreenCoordinate) {
205234
* @return Whether this event was handled by this element. Always true.
206235
*/
207236
bool GameController::handleBoardEvent(ScreenCoordinate screenCoord) {
208-
printPlayerInfo(model.getCurrentPlayer());
209237
auto coord = screenToCoord(screenCoord);
210238
std::vector<Settlement*> neighbors;
211239

0 commit comments

Comments
 (0)