diff options
| author | Crystalwarrior <varsash@gmail.com> | 2020-02-24 22:20:43 +0300 |
|---|---|---|
| committer | Crystalwarrior <varsash@gmail.com> | 2020-02-24 22:20:43 +0300 |
| commit | a4e448576b43b9cf4f984253abb3daf7296aa154 (patch) | |
| tree | 7331922ec7176feb0bbbb2bc3ac5b06267279062 /src | |
| parent | 9df7b9648ae1bd694f99fa6748eee547752b6c9c (diff) | |
Make pos dropdown more abstract and actually useful by letting servers send only pos you can actually access.
Pos dropdown system also reads the actual bg folder of the current BG to see all the created pos.
Diffstat (limited to 'src')
| -rw-r--r-- | src/courtroom.cpp | 79 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 9 |
2 files changed, 45 insertions, 43 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 81e043ef..ea6f1659 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -180,14 +180,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() initialize_emotes(); ui_pos_dropdown = new QComboBox(this); - ui_pos_dropdown->addItem("wit"); - ui_pos_dropdown->addItem("def"); - ui_pos_dropdown->addItem("pro"); - ui_pos_dropdown->addItem("jud"); - ui_pos_dropdown->addItem("hld"); - ui_pos_dropdown->addItem("hlp"); - ui_pos_dropdown->addItem("jur"); - ui_pos_dropdown->addItem("sea"); ui_iniswap_dropdown = new QComboBox(this); ui_iniswap_dropdown->setContextMenuPolicy(Qt::CustomContextMenu); @@ -1005,10 +997,32 @@ void Courtroom::set_background(QString p_background, bool display) ui_vp_testimony->stop(); current_background = p_background; + //welcome to hardcode central may I take your order of regularly scheduled CBT + QMap<QString, QString> default_pos; + default_pos["defenseempty"] = "def"; + default_pos["helperstand"] = "hld"; + default_pos["prosecutorempty"] = "pro"; + default_pos["prohelperstand"] = "hlp"; + default_pos["witnessempty"] = "wit"; + default_pos["judgestand"] = "jud"; + default_pos["jurystand"] = "jur"; + default_pos["seancestand"] = "sea"; + + //Populate the dropdown list with all pos that exist on this bg + QStringList pos_list = {}; + for (QString key : default_pos.keys()) + { + if (file_exists(ao_app->get_static_image_suffix(ao_app->get_background_path(key)))) + { + pos_list.append(default_pos[key]); + } + } + + //TODO: search through extra/custom pos and add them to the pos dropdown as well + + set_pos_dropdown(pos_list); + is_ao2_bg = true; -// file_exists(ao_app->get_static_image_suffix(ao_app->get_background_path("defensedesk"))) && -// file_exists(ao_app->get_static_image_suffix(ao_app->get_background_path("prosecutiondesk"))) && -// file_exists(ao_app->get_static_image_suffix(ao_app->get_background_path("stand"))); if (is_ao2_bg) { @@ -1070,6 +1084,13 @@ void Courtroom::set_side(QString p_side) } } +void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) +{ + pos_dropdown_list = pos_dropdowns; + ui_pos_dropdown->clear(); + ui_pos_dropdown->addItems(pos_dropdown_list); + qDebug() << pos_dropdown_list; +} void Courtroom::update_character(int p_cid) { @@ -3336,42 +3357,14 @@ void Courtroom::on_pos_dropdown_changed(int p_index) toggle_judge_buttons(false); - QString f_pos; - - switch (p_index) - { - case 0: - f_pos = "wit"; - break; - case 1: - f_pos = "def"; - break; - case 2: - f_pos = "pro"; - break; - case 3: - f_pos = "jud"; - toggle_judge_buttons(true); - break; - case 4: - f_pos = "hld"; - break; - case 5: - f_pos = "hlp"; - break; - case 6: - f_pos = "jur"; - break; - case 7: - f_pos = "sea"; - break; - default: - f_pos = ""; - } + QString f_pos = ui_pos_dropdown->itemText(p_index); if (f_pos == "") return; + if (f_pos == "jud") + toggle_judge_buttons(true); + //YEAH SENDING LIKE 20 PACKETS IF THE USER SCROLLS THROUGH, GREAT IDEA //how about this instead set_side(f_pos); diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 8c74b768..23050836 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -595,7 +595,16 @@ void AOApplication::server_packet_received(AOPacket *p_packet) goto end; if (courtroom_constructed) //We were sent a "set position" packet + { w_courtroom->set_side(f_contents.at(0)); + } + } + else if (header == "SD") //Send pos dropdown + { + if (f_contents.size() < 1) + goto end; + + w_courtroom->set_pos_dropdown(f_contents.at(0).split("*")); } //server accepting char request(CC) packet else if (header == "PV") |
