Player12
An open source football management simulator
Loading...
Searching...
No Matches
offer_negotiation_dialog.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// Football Management Project
3// Copyright (c) 2025 - 2026 Flavio Milinanni. All Rights Reserved.
4//
5// This file is part of the Football Management Project.
6// See the LICENSE file in the project root.
7// -----------------------------------------------------------------------------
8
9#pragma once
10
11#include <imgui.h>
12
13#include <array>
14#include <cstdint>
15#include <optional>
16#include <string>
17#include <string_view>
18#include <vector>
19
21#include "gui/widgets/widgets.h"
23
43{
44 public:
46 void open(GameController& controller, std::uint32_t offer_id);
47
52 bool render(GameController& controller);
53
54 [[nodiscard]] bool isOpen() const { return visible; }
55
56 private:
58
59 enum class Mode : int
60 {
61 Counter = 0,
62 NamePrice = 1
63 };
64
65 struct Line
66 {
67 std::string label;
68 std::string value;
69 };
70
71 struct RoundLine
72 {
73 std::string who;
74 std::string text;
75 std::string detail;
76 bool buyer = false;
77 };
78
79 void rebuild(const GameController& controller);
84 void rebuildLoanLines();
85 void renderHeader() const;
86 void renderBid() const;
87 void renderHistory() const;
88 void renderAnswer();
89 void renderActions(GameController& controller);
90 void renderResult() const;
91
92 void accept(GameController& controller);
93 void reject(GameController& controller);
94 void notForSale(GameController& controller);
95 void submit(GameController& controller);
97 void finish(std::string_view headline, const ImVec4& color,
98 std::string_view detail);
99
100 std::uint32_t offer_id = 0;
101 bool open_requested = false;
102 bool visible = false;
103 bool changed = false;
104 std::optional<GameController::IncomingOfferView> view;
105
106 // Built by rebuild().
107 std::string title;
108 std::string subtitle;
109 std::string stance_text;
110 ImVec4 stance_color{};
111 std::vector<Line> facts;
112 std::vector<Line> bid_lines;
113 std::string bid_total;
114 std::vector<RoundLine> rounds;
115 std::string status_text;
116 ImVec4 status_color{};
117 std::string proposal_text;
118 std::vector<UI::MoneyChip> counter_chips;
119 std::array<UI::MoneyChip, 4> price_chips{};
120
121 // The club's answer being prepared.
125 std::int64_t price = 0;
128 std::string loan_wage_text;
129 std::string loan_saving_text;
130 std::string notice;
131 ImVec4 notice_color{};
132
133 // End of the talks.
134 bool finished = false;
135 std::string result_headline;
136 ImVec4 result_color{};
137 std::string result_detail;
138};
Manages the core game logic, interacting with teams, leagues, and players.
Definition game_controller.h:70
Modal talks over an AI club's bid for one of the managed players, or its offer to borrow him.
Definition offer_negotiation_dialog.h:43
ImVec4 notice_color
Definition offer_negotiation_dialog.h:131
ImVec4 status_color
Definition offer_negotiation_dialog.h:116
void renderHeader() const
Definition offer_negotiation_dialog.cpp:439
void accept(GameController &controller)
Definition offer_negotiation_dialog.cpp:635
std::string proposal_text
Definition offer_negotiation_dialog.h:117
void renderAnswer()
Definition offer_negotiation_dialog.cpp:489
std::string stance_text
Definition offer_negotiation_dialog.h:109
std::string title
Definition offer_negotiation_dialog.h:107
void submit(GameController &controller)
Definition offer_negotiation_dialog.cpp:713
std::string status_text
Definition offer_negotiation_dialog.h:115
ImVec4 stance_color
Definition offer_negotiation_dialog.h:110
std::vector< Line > bid_lines
Definition offer_negotiation_dialog.h:112
void refreshCounterTexts()
Definition offer_negotiation_dialog.cpp:126
Mode mode
Definition offer_negotiation_dialog.h:122
std::string loan_saving_text
Definition offer_negotiation_dialog.h:129
Mode
Definition offer_negotiation_dialog.h:60
void rebuildLoanLines()
Definition offer_negotiation_dialog.cpp:313
bool changed
Definition offer_negotiation_dialog.h:103
void notForSale(GameController &controller)
Definition offer_negotiation_dialog.cpp:698
void renderHistory() const
Definition offer_negotiation_dialog.cpp:470
std::string result_headline
Definition offer_negotiation_dialog.h:135
void renderBid() const
Definition offer_negotiation_dialog.cpp:458
bool open_requested
Definition offer_negotiation_dialog.h:101
void finish(std::string_view headline, const ImVec4 &color, std::string_view detail)
Definition offer_negotiation_dialog.cpp:625
void renderResult() const
Definition offer_negotiation_dialog.cpp:609
std::string counter_worth_text
Definition offer_negotiation_dialog.h:127
TransferNegotiation::LoanTerms loan_counter
Definition offer_negotiation_dialog.h:124
TransferNegotiation::OfferTerms counter
Definition offer_negotiation_dialog.h:123
std::int64_t price
Definition offer_negotiation_dialog.h:125
std::string subtitle
Definition offer_negotiation_dialog.h:108
std::vector< Line > facts
Definition offer_negotiation_dialog.h:111
ImVec4 result_color
Definition offer_negotiation_dialog.h:136
bool visible
Definition offer_negotiation_dialog.h:102
std::string result_detail
Definition offer_negotiation_dialog.h:137
std::string notice
Definition offer_negotiation_dialog.h:130
void rebuildTransferLines()
Definition offer_negotiation_dialog.cpp:271
std::string bid_total
Definition offer_negotiation_dialog.h:113
void renderActions(GameController &controller)
Definition offer_negotiation_dialog.cpp:550
std::uint32_t offer_id
Definition offer_negotiation_dialog.h:100
void open(GameController &controller, std::uint32_t offer_id)
Definition offer_negotiation_dialog.cpp:97
bool finished
Definition offer_negotiation_dialog.h:134
std::string counter_upfront_text
Definition offer_negotiation_dialog.h:126
std::string loan_wage_text
Definition offer_negotiation_dialog.h:128
bool isOpen() const
Definition offer_negotiation_dialog.h:54
std::vector< RoundLine > rounds
Definition offer_negotiation_dialog.h:114
void rebuild(const GameController &controller)
Definition offer_negotiation_dialog.cpp:148
std::vector< UI::MoneyChip > counter_chips
Definition offer_negotiation_dialog.h:118
std::array< UI::MoneyChip, 4 > price_chips
Definition offer_negotiation_dialog.h:119
bool render(GameController &controller)
Definition offer_negotiation_dialog.cpp:356
std::optional< GameController::IncomingOfferView > view
Definition offer_negotiation_dialog.h:104
friend class GameFlowTest_GUIFlowLifecycle_Test
Definition offer_negotiation_dialog.h:57
void reject(GameController &controller)
Definition offer_negotiation_dialog.cpp:682
Definition offer_negotiation_dialog.h:66
std::string label
Definition offer_negotiation_dialog.h:67
std::string value
Definition offer_negotiation_dialog.h:68
Definition offer_negotiation_dialog.h:72
bool buyer
Definition offer_negotiation_dialog.h:76
std::string detail
Definition offer_negotiation_dialog.h:75
std::string text
Definition offer_negotiation_dialog.h:74
std::string who
Definition offer_negotiation_dialog.h:73
Definition transfer_negotiation.h:299
A club-to-club offer: fee, instalments, add-ons and sell-on.
Definition transfer_negotiation.h:100