@@ -660,11 +660,19 @@ void DrawingGameVisitor::visit(DevelopmentCard& card) {
660660 * @param initialOffer The initial offer to display.
661661 */
662662TradingView::TradingView (Player& initiating, Player& receiving, std::function<bool (std::array<int , 5 >, ScreenCoordinate)> trade, std::function<bool(ScreenCoordinate)> cancel, std::array<int, 5> initialOffer) :
663- ViewElement({{0.1 , 0.1 },{0.9 , 0.9 }}), initiating(initiating), receiving(receiving),
664- trade(std::bind(trade, std::ref(offer), std::placeholders::_1), {{0.7 , 0.1 }, {0.9 , 0.2 }}, getGraphicsConfig()[" font.path" ], getGraphicsConfig()[" font.size" ], " Trade" ),
665- cancel (cancel, {{0.1 , 0.1 }, {0.3 , 0.2 }}, getGraphicsConfig()["font.path"], getGraphicsConfig()["font.size"], "Cancel"),
663+ ViewElement({getGraphicsConfig ()[" screen.tradingView.bottomLeft" ], getGraphicsConfig ()[" screen.tradingView.topRight" ]}),
664+ initiating(initiating),
665+ receiving(receiving),
666+ trade(
667+ std::bind (trade, std::ref(offer), std::placeholders::_1),
668+ {getGraphicsConfig ()[" screen.tradingView.tradeButton.bottomLeft" ], getGraphicsConfig ()[" screen.tradingView.tradeButton.topRight" ]},
669+ getGraphicsConfig ()["font.path"], getGraphicsConfig()["font.size"], "Trade"
670+ ),
671+ cancel(cancel,
672+ {getGraphicsConfig ()[" screen.tradingView.cancelButton.bottomLeft" ], getGraphicsConfig ()[" screen.tradingView.cancelButton.topRight" ]},
673+ getGraphicsConfig ()["font.path"], getGraphicsConfig()["font.size"], "Cancel"
674+ ),
666675 offer(initialOffer) {
667-
668676}
669677
670678/* *
@@ -685,7 +693,7 @@ bool TradingView::clicked(ScreenCoordinate coord) {
685693 return true ;
686694 }
687695 int modifier = coord.first <= 0.5 ? -1 : 1 ;
688- int resource = (coord.second - 0.2 ) / 0.13 ;
696+ int resource = (coord.second - getGraphicsConfig ()[ " screen.tradingView.resources.bottomY " ] ) / getGraphicsConfig ()[ " screen.tradingView.resources.height " ] ;
689697 if (resource >= 0 && resource <= 5 ) {
690698 offer[resource] += modifier;
691699 }
@@ -712,10 +720,15 @@ void TradingView::render() {
712720
713721 std::string resources[] = {" Wood" , " Brick" , " Ore" , " Wheat" , " Wool" };
714722 for (int i = 0 ; i < 5 ; i++) {
715- auto height = 0.13 ;
716- renderText (font, fontSize, {0.3 , 0.2 + (i * height)}, {0.6 , 0.2 + height + (i * height)}, toString (offer[i]) + " " + resources[i]);
723+ auto leftX = getGraphicsConfig ()[" screen.tradingView.resources.leftX" ];
724+ auto rightX = getGraphicsConfig ()[" screen.tradingView.resources.rightX" ];
725+ auto height = getGraphicsConfig ()[" screen.tradingView.resources.height" ];
726+ auto bottomY = getGraphicsConfig ()[" screen.tradingView.resources.bottomY" ];
727+ renderText (font, fontSize, {leftX, bottomY + (i * height)}, {rightX, bottomY + height + (i * height)}, toString (offer[i]) + " " + resources[i]);
717728 }
718- renderText (font, fontSize, {0.1 , 0.8 }, {0.9 , 0.9 }, initiating.getName () + " -> " + receiving.getName ());
729+ auto playersBottomLeft = getGraphicsConfig ()[" screen.tradingView.players.bottomLeft" ];
730+ auto playersTopRight = getGraphicsConfig ()[" screen.tradingView.players.topRight" ];
731+ renderText (font, fontSize, playersBottomLeft, playersTopRight, initiating.getName () + " -> " + receiving.getName ());
719732
720733 cancel.render ();
721734 trade.render ();
@@ -734,10 +747,10 @@ ConfirmationDialogue::ConfirmationDialogue(std::function<bool(ScreenCoordinate)>
734747 ScreenCoordinate confirmBottomRight = ScreenCoordinate (bottomRight.first - (width * .6 ), bottomRight.second - (height * .6 ));
735748 ScreenCoordinate cancelTopLeft = ScreenCoordinate (topLeft.first + (width*.6 ), topLeft.second + (height *.1 ));
736749 ScreenCoordinate cancelBottomRight = ScreenCoordinate (bottomRight.first - (width * .1 ), bottomRight.second - (height * .6 ));
737-
738- auto font = " resources/ComicNeue-Bold.ttf " ;
739- auto fontSize = 50 ;
740-
750+
751+ auto font = getGraphicsConfig ()[ " font.path " ] ;
752+ auto fontSize = getGraphicsConfig ()[ " font.size " ] ;
753+
741754 confirmButton = std::unique_ptr<ViewElement>(new ViewButtonText (confirm_action, {confirmTopLeft, confirmBottomRight}, font, fontSize, " Yes" ));
742755 cancelButton = std::unique_ptr<ViewElement>(new ViewButtonText (cancel_action, {cancelTopLeft, cancelBottomRight}, font, fontSize, " No" ));
743756}
0 commit comments