]> granicus.if.org Git - nethack/commitdiff
Fix YN function in Qt windowport compact mode (wasn't parsing properly).
authorwarwick <warwick>
Sun, 13 Jan 2002 00:33:02 +0000 (00:33 +0000)
committerwarwick <warwick>
Sun, 13 Jan 2002 00:33:02 +0000 (00:33 +0000)
Often, the yn_function "choices" parameter is not set, so for a non-keyboard
GUI (compact mode is for handheld computers with a stylus), the windowport
has to parse the prompt to find out the posible input choices. I got the
parsing wrong.

win/Qt/qt_win.cpp

index 5aba22bf35dd56cffab1138f502afee5ceb562eb..c9e4302ad3a2e915f34f927762dcc30fe80e454a 100644 (file)
@@ -3946,6 +3946,7 @@ char NetHackQtYnDialog::Exec()
     QString enable;
     if ( qt_compact_mode && !choices ) {
        // expand choices from prompt
+       // ##### why isn't choices set properly???
        const char* c=question;
        while ( *c && *c != '[' )
            c++;
@@ -3956,13 +3957,16 @@ char NetHackQtYnDialog::Exec()
                ch.append(*c++);
            char from=0;
            while ( *c && *c != ']' && *c != ' ' ) {
-               if ( *c == '-' )
+               if ( *c == '-' ) {
                    from = c[-1];
-               else if ( from )
-                   for (char f=from; f<=*c; f++)
+               } else if ( from ) {
+                   for (char f=from+1; f<=*c; f++)
                        ch.append(f);
-               else
+                   from = 0;
+               } else {
                    ch.append(*c);
+                   from = 0;
+               }
                c++;
            }
            if ( *c == ' ' ) {
@@ -4415,8 +4419,10 @@ NetHackQtSavedGameSelector::NetHackQtSavedGameSelector(const char** saved) :
 
 int NetHackQtSavedGameSelector::choose()
 {
+#if defined(QWS) // probably safe with Qt 3, too (where show!=exec in QDialog).
     if ( qt_compact_mode )
        showMaximized();
+#endif
     return exec()-2;
 }