Show key combinations in controls config menu (read-only)
authorWuzzy <Wuzzy2@mail.ru>
Sat, 27 Apr 2019 19:14:00 +0200
changeset 14867 75b515a64202
parent 14866 6c51f74d80a8
child 14868 eef1f76150fe
Show key combinations in controls config menu (read-only)
QTfrontend/binds.cpp
QTfrontend/binds.h
QTfrontend/ui/widget/keybinder.cpp
--- a/QTfrontend/binds.cpp	Sat Apr 27 15:13:33 2019 +0200
+++ b/QTfrontend/binds.cpp	Sat Apr 27 19:14:00 2019 +0200
@@ -25,9 +25,12 @@
     {"+right",    "right",      QT_TRANSLATE_NOOP("binds", "right"),           NULL, NULL},
     {"+down",     "down",       QT_TRANSLATE_NOOP("binds", "down"),            NULL, NULL},
     {"+precise",  "left_shift", QT_TRANSLATE_NOOP("binds", "precise aim"),     NULL, NULL},
+    {"!MULTI",    QT_TRANSLATE_NOOP("binds (combination)", "hold down precise"), QT_TRANSLATE_NOOP("binds", "stand still on slippery land"), NULL, NULL},
+    {"!MULTI",    QT_TRANSLATE_NOOP("binds (combination)", "precise + left/right"), QT_TRANSLATE_NOOP("binds", "change direction without moving"), NULL, NULL},
     {"ljump",     "return",     QT_TRANSLATE_NOOP("binds", "long jump"),       NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Traverse gaps and obstacles by jumping:")},
     {"hjump",     "backspace",  QT_TRANSLATE_NOOP("binds", "high jump"),       NULL, NULL},
     {"switch",    "tab",        QT_TRANSLATE_NOOP("binds", "switch"),          NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Switch your currently active hog (if possible):")},
+    {"!MULTI",    QT_TRANSLATE_NOOP("binds (combination)", "precise + switch"), QT_TRANSLATE_NOOP("binds", "switch backwards"), NULL, NULL},
     {"ammomenu",  "mouser",     QT_TRANSLATE_NOOP("binds", "ammo menu"),       QT_TRANSLATE_NOOP("binds (categories)", "Weapons"), QT_TRANSLATE_NOOP("binds (descriptions)", "Pick a weapon or utility item:")},
     {"slot 1",    "f1",         QT_TRANSLATE_NOOP("binds", "slot 1"),          NULL, NULL},
     {"slot 2",    "f2",         QT_TRANSLATE_NOOP("binds", "slot 2"),          NULL, NULL},
@@ -46,6 +49,7 @@
     {"timer 4",   "4",          QT_TRANSLATE_NOOP("binds", "timer 4 sec"),     NULL, NULL},
     {"timer 5",   "5",          QT_TRANSLATE_NOOP("binds", "timer 5 sec"),     NULL, NULL},
     {"timer_u",   "n",          QT_TRANSLATE_NOOP("binds", "change timer"),    NULL, NULL},
+    {"!MULTI",    QT_TRANSLATE_NOOP("binds (combination)", "precise + timer"), QT_TRANSLATE_NOOP("binds", "change bounciness"), NULL, NULL},
     {"+attack",   "space",      QT_TRANSLATE_NOOP("binds", "attack"),          NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Fire your selected weapon or trigger an utility item:")},
     {"put",       "mousel",     QT_TRANSLATE_NOOP("binds", "put"),             NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Pick a weapon or a target location under the cursor:")},
     {"findhh",    "h",          QT_TRANSLATE_NOOP("binds", "autocam / find hedgehog"),QT_TRANSLATE_NOOP("binds (categories)", "Camera"), QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle automatic camera / refocus on active hedgehog:")},
@@ -56,7 +60,8 @@
 //  {"+cur_m",    "",           QT_TRANSLATE_NOOP("binds", "movement key modifier"),    NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Specify a modifier key to move camera and cursor using your default hog movement keys:")},
     {"zoomin",    "wheelup",    QT_TRANSLATE_NOOP("binds", "zoom in"),         NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the camera's zoom level:")},
     {"zoomout",   "wheeldown",  QT_TRANSLATE_NOOP("binds", "zoom out"),        NULL, NULL},
-    {"zoomreset", "mousem",     QT_TRANSLATE_NOOP("binds", "reset zoom"),      NULL, NULL},
+    {"zoomreset", "mousem",     QT_TRANSLATE_NOOP("binds", "reset zoom to start value"), NULL, NULL},
+    {"!MULTI",    QT_TRANSLATE_NOOP("binds (combination)", "precise + reset zoom"), QT_TRANSLATE_NOOP("binds", "set zoom to 100%"), NULL, NULL},
     {"chat",      "t",          QT_TRANSLATE_NOOP("binds", "chat"),            QT_TRANSLATE_NOOP("binds (categories)", "Miscellaneous"), QT_TRANSLATE_NOOP("binds (descriptions)", "Talk to your clan or all participants:")},
     {"chat team", "u",          QT_TRANSLATE_NOOP("binds", "clan chat"),       NULL, NULL},
     {"history",   "`",          QT_TRANSLATE_NOOP("binds", "chat history"),    NULL, NULL},
@@ -68,12 +73,17 @@
     {"mute",      "8",          QT_TRANSLATE_NOOP("binds", "mute audio"),      NULL, NULL},
     {"fullscr",   "f12",        QT_TRANSLATE_NOOP("binds", "change mode"),     NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle fullscreen mode:")},
     {"capture",   "c",          QT_TRANSLATE_NOOP("binds", "capture"),         NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Take a screenshot:")},
+    {"!MULTI",    QT_TRANSLATE_NOOP("binds (combination)", "precise + capture"), QT_TRANSLATE_NOOP("binds", "save map as image"), NULL, NULL},
     {"+speedup",  "s",          QT_TRANSLATE_NOOP("binds", "speed up replay"),         NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Demo replay:")},
     {"+mission",  "m",          QT_TRANSLATE_NOOP("binds", "show mission information"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Heads-up display:")},
     {"gearinfo",  "o",          QT_TRANSLATE_NOOP("binds", "show object information"), NULL, NULL},
     //: This refers to the team info bars (name/flag/health) of all teams. These are shown at the bottom center of the screen
     {"rotmask",   "delete",     QT_TRANSLATE_NOOP("binds", "toggle team bars"), NULL, NULL},
     {"rottags",   "home",       QT_TRANSLATE_NOOP("binds", "toggle hedgehog tags"), NULL, NULL},
+    {"!MULTI",    QT_TRANSLATE_NOOP("binds (combination)", "precise + toggle hedgehog tags"), QT_TRANSLATE_NOOP("binds", "change hedgehog tag types"), NULL, NULL},
+    {"!MULTI",    QT_TRANSLATE_NOOP("binds (combination)", "switch + toggle hedgehog tags"), QT_TRANSLATE_NOOP("binds", "toggle hedgehog tag translucency"), NULL, NULL},
+
+    {"!MULTI",    QT_TRANSLATE_NOOP("binds (combination)", "precise + switch + toggle hedgehog tags"), QT_TRANSLATE_NOOP("binds", "toggle HUD"), NULL, NULL},
 #ifdef VIDEOREC
     {"record",    "r",          QT_TRANSLATE_NOOP("binds", "record"),          NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Record video:")}
 #endif
--- a/QTfrontend/binds.h	Sat Apr 27 15:13:33 2019 +0200
+++ b/QTfrontend/binds.h	Sat Apr 27 19:14:00 2019 +0200
@@ -22,9 +22,9 @@
 #include <QString>
 
 #ifdef VIDEOREC
-#define BINDS_NUMBER 53
+#define BINDS_NUMBER 62
 #else
-#define BINDS_NUMBER 52
+#define BINDS_NUMBER 61
 #endif
 
 struct BindAction
--- a/QTfrontend/ui/widget/keybinder.cpp	Sat Apr 27 15:13:33 2019 +0200
+++ b/QTfrontend/ui/widget/keybinder.cpp	Sat Apr 27 19:14:00 2019 +0200
@@ -117,6 +117,16 @@
     selectedBindTable = NULL;
     bindComboBoxCellMappings = new QHash<QObject *, QTableWidgetItem *>();
     bindCellComboBoxMappings = new QHash<QTableWidgetItem *, QComboBox *>();
+
+    QIcon dropDownIcon = QIcon();
+    QPixmap dd1 = QPixmap(":/res/dropdown.png");
+    QPixmap dd2 = QPixmap(":/res/dropdown_selected.png");
+    dropDownIcon.addPixmap(dd1, QIcon::Normal);
+    dropDownIcon.addPixmap(dd2, QIcon::Selected);
+    QPixmap emptySpace = QPixmap(16, 16);
+    emptySpace.fill(QColor(0, 0, 0, 0));
+    QIcon emptyIcon = QIcon(emptySpace);
+
     for (int i = 0; i < BINDS_NUMBER; i++)
     {
         if (cbinds[i].category != NULL)
@@ -167,37 +177,55 @@
         }
 
         // Hidden combo box
-        QComboBox * comboBox = CBBind[i] = new QComboBox(curTable);
-        comboBox->setModel((QAbstractItemModel*)DataManager::instance().bindsModel());
-        comboBox->setVisible(false);
-        comboBox->setMinimumWidth(400);
-        comboBox->setMaxVisibleItems(50);
+        QComboBox * comboBox;
+        if (cbinds[i].action != "!MULTI")
+        {
+            comboBox = CBBind[i] = new QComboBox(curTable);
+            comboBox->setModel((QAbstractItemModel*)DataManager::instance().bindsModel());
+            comboBox->setVisible(false);
+            comboBox->setMinimumWidth(400);
+            comboBox->setMaxVisibleItems(50);
+        }
+        else
+        {
+            comboBox = CBBind[i] = NULL;
+        }
 
         // Table row
         int row = curTable->rowCount();
         QTableWidgetItem * nameCell = new QTableWidgetItem(HWApplication::translate("binds", cbinds[i].name));
-        nameCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
         curTable->insertRow(row);
         curTable->setItem(row, 0, nameCell);
-        QTableWidgetItem * bindCell = new QTableWidgetItem(comboBox->currentText());
-        QIcon dropDownIcon = QIcon();
-        QPixmap dd1 = QPixmap(":/res/dropdown.png");
-        QPixmap dd2 = QPixmap(":/res/dropdown_selected.png");
-        dropDownIcon.addPixmap(dd1, QIcon::Normal);
-        dropDownIcon.addPixmap(dd2, QIcon::Selected);
-        bindCell->setIcon(dropDownIcon);
-        bindCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+        QTableWidgetItem * bindCell;
+        if (cbinds[i].action != "!MULTI")
+        {
+            bindCell = new QTableWidgetItem(comboBox->currentText());
+            nameCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+            bindCell->setIcon(dropDownIcon);
+            bindCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+        }
+        else
+        {
+            bindCell = new QTableWidgetItem(HWApplication::translate("binds (combination)", cbinds[i].strbind.toUtf8().constData()));
+            nameCell->setFlags(Qt::NoItemFlags);
+            bindCell->setFlags(Qt::NoItemFlags);
+            bindCell->setIcon(emptyIcon);
+        }
         curTable->setItem(row, 1, bindCell);
         curTable->resizeColumnsToContents();
         curTable->setFixedHeight(curTable->verticalHeader()->length() + 10);
 
-        // Updates the text in the table cell
-        connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(bindChanged(const QString &)));
+        if (cbinds[i].action != "!MULTI")
+        {
+            // Updates the text in the table cell
+            connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(bindChanged(const QString &)));
 
-        // Map combo box and that row's cells to each other
-        bindComboBoxCellMappings->insert(comboBox, bindCell);
-        bindCellComboBoxMappings->insert(nameCell, comboBox);
-        bindCellComboBoxMappings->insert(bindCell, comboBox);
+            // Map combo box and that row's cells to each other
+            bindComboBoxCellMappings->insert(comboBox, bindCell);
+            bindCellComboBoxMappings->insert(nameCell, comboBox);
+            bindCellComboBoxMappings->insert(bindCell, comboBox);
+        }
+
     }
 
     // Add stretch at end of last layout
@@ -247,6 +275,8 @@
 void KeyBinder::bindCellClicked(QTableWidgetItem * item)
 {
     QComboBox * box = bindCellComboBoxMappings->value(item);
+    if(box == NULL)
+        return;
     QTableWidget * table = item->tableWidget();
 
     box->move(
@@ -272,14 +302,18 @@
 void KeyBinder::setBindIndex(int keyIndex, int bindIndex)
 {
     enableSignal = false;
-    CBBind[keyIndex]->setCurrentIndex(bindIndex);
+    if(CBBind[keyIndex] != NULL)
+        CBBind[keyIndex]->setCurrentIndex(bindIndex);
     enableSignal = true;
 }
 
 // Return a combobox's selected index
 int KeyBinder::bindIndex(int keyIndex)
 {
-    return CBBind[keyIndex]->currentIndex();
+    if(CBBind[keyIndex] != NULL)
+        return CBBind[keyIndex]->currentIndex();
+    else
+        return 0;
 }
 
 // Clears selection and goes to first category
@@ -299,9 +333,12 @@
     DataManager::instance().bindsModel()->item(0)->setData(defaultText, Qt::DisplayRole);
     for (int i = 0; i < BINDS_NUMBER; i++)
     {
-        CBBind[i]->setModel(DataManager::instance().bindsModel());
-        CBBind[i]->setCurrentIndex(0);
-        bindComboBoxCellMappings->value(CBBind[i])->setText(defaultText);
+        if (CBBind[i] != NULL)
+        {
+            CBBind[i]->setModel(DataManager::instance().bindsModel());
+            CBBind[i]->setCurrentIndex(0);
+            bindComboBoxCellMappings->value(CBBind[i])->setText(defaultText);
+        }
     }
 
     enableSignal = true;