QTfrontend/ui/page/pagemain.cpp
branchwebgl
changeset 8330 aaefa587e277
parent 8318 e2c01fbf36c0
child 8444 75db7bb8dce8
equal deleted inserted replaced
8116:d24257910f8d 8330:aaefa587e277
    44     BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true);
    44     BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true);
    45     BtnSinglePlayer->setToolTip(tr("Local Game"));
    45     BtnSinglePlayer->setToolTip(tr("Local Game"));
    46     BtnSinglePlayer->setWhatsThis(tr("Play a game on a single computer"));
    46     BtnSinglePlayer->setWhatsThis(tr("Play a game on a single computer"));
    47     pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter);
    47     pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter);
    48 
    48 
       
    49     //BtnNet = addButton(":/res/NetworkPlay.png", (QBoxLayout*)netLayout, 1, true);
    49     BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true);
    50     BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true);
    50     BtnNet->setToolTip(tr("Network Game"));
    51     BtnNet->setToolTip(tr("Network Game"));
    51     BtnNet->setWhatsThis(tr("Play a game across a network"));
    52     BtnNet->setWhatsThis(tr("Play a game across a network"));
    52     pageLayout->setAlignment(BtnNet, Qt::AlignHCenter);
    53     pageLayout->setAlignment(BtnNet, Qt::AlignHCenter);
       
    54     connect(BtnNet, SIGNAL(clicked()), this, SLOT(toggleNetworkChoice()));
       
    55 
       
    56     originalNetworkIcon = BtnNet->icon();
       
    57     disabledNetworkIcon = QIcon(":/res/NetworkPlayDisabled.png");
       
    58 
       
    59     //QWidget *netLayoutWidget = new QWidget();
       
    60     QVBoxLayout *netLayout = new QVBoxLayout(BtnNet);
       
    61     //pageLayout->addWidget(netLayoutWidget, 2, 2, 1, 2);
       
    62     //netLayoutWidget->setStyleSheet("background: green;");
       
    63     //netLayoutWidget->setFixedSize(314, 260);
       
    64     netLayout->setSpacing(20);
       
    65     netLayout->setAlignment(Qt::AlignHCenter);
       
    66 
       
    67     BtnNetLocal = addButton("Play local network game", (QBoxLayout*)netLayout, 0, false);
       
    68     BtnNetLocal->setToolTip(tr("Play a local network game"));
       
    69     BtnNetLocal->setWhatsThis(tr("Play a game across a local area network"));
       
    70     BtnNetLocal->setFixedSize(BtnNet->width() - 50, 60);
       
    71     BtnNetLocal->setVisible(false);
       
    72 
       
    73     BtnNetOfficial = addButton("Play official network game", (QBoxLayout*)netLayout, 0, false);
       
    74     BtnNetOfficial->setToolTip(tr("Play a network game"));
       
    75     BtnNetOfficial->setWhatsThis(tr("Play a game on an official server"));
       
    76     BtnNetOfficial->setFixedSize(BtnNet->width() - 50, 60);
       
    77     BtnNetOfficial->setVisible(false);
    53 
    78 
    54     // button order matters for overlapping (what's on top and what isn't)
    79     // button order matters for overlapping (what's on top and what isn't)
    55     BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true);
    80     BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true);
    56     BtnInfo->setStyleSheet("border: transparent;background: transparent;");
    81     BtnInfo->setStyleSheet("border: transparent;background: transparent;");
    57     //BtnInfo->setToolTip(tr("Credits")); //tooltip looks horrible with transparent background buttons
    82     //BtnInfo->setToolTip(tr("Credits")); //tooltip looks horrible with transparent background buttons
    58     BtnInfo->setWhatsThis(tr("Read about who is behind the Hedgewars Project"));
    83     BtnInfo->setWhatsThis(tr("Read about who is behind the Hedgewars Project"));
    59     pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter);
    84     pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter);
    60 
    85 
    61     BtnFeedback = addButton("Feedback", pageLayout, 4, 0, 1, 4, false);
    86     BtnFeedback = addButton("Feedback", pageLayout, 4, 0, 1, 4, false);
       
    87     BtnFeedback->setFixedSize(86, 27);
    62     BtnFeedback->setWhatsThis(tr("Leave a feedback here reporting issues, suggesting features or just saying how you like Hedgewars"));
    88     BtnFeedback->setWhatsThis(tr("Leave a feedback here reporting issues, suggesting features or just saying how you like Hedgewars"));
    63     pageLayout->setAlignment(BtnFeedback, Qt::AlignHCenter);
    89     pageLayout->setAlignment(BtnFeedback, Qt::AlignHCenter);
    64 
    90 
    65     BtnDataDownload = addButton(tr("Downloadable Content"), pageLayout, 5, 0, 1, 4, false);
    91     BtnDataDownload = addButton(tr("Downloadable Content"), pageLayout, 5, 0, 1, 4, false);
       
    92     BtnDataDownload->setFixedSize(176, 27);
    66     //BtnDataDownload->setToolTip(tr(Downloadable Content"));
    93     //BtnDataDownload->setToolTip(tr(Downloadable Content"));
    67     BtnDataDownload->setWhatsThis(tr("Access the user created content downloadable from our website"));
    94     BtnDataDownload->setWhatsThis(tr("Access the user created content downloadable from our website"));
    68     pageLayout->setAlignment(BtnDataDownload, Qt::AlignHCenter);
    95     pageLayout->setAlignment(BtnDataDownload, Qt::AlignHCenter);
    69 
    96 
    70     // disable exit button sound
    97     // disable exit button sound
   113     {
   140     {
   114         setDefautDescription(QLabel::tr("Tip: ") + randomTip());
   141         setDefautDescription(QLabel::tr("Tip: ") + randomTip());
   115     }
   142     }
   116     else
   143     else
   117     {
   144     {
   118         setDefautDescription(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game. Some features might be broken or incomplete. Use at your own risk!"));
   145         setDefautDescription(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game, while some features might be broken or incomplete!"));
   119     }
   146     }
   120 
   147 
   121 }
   148 }
   122 
   149 
   123 QString PageMain::randomTip() const
   150 QString PageMain::randomTip() const
   180     Tips << tr("You can find your Hedgewars configuration files under \".hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips");
   207     Tips << tr("You can find your Hedgewars configuration files under \".hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips");
   181 #endif
   208 #endif
   182 
   209 
   183     return Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()];
   210     return Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()];
   184 }
   211 }
       
   212 
       
   213 void PageMain::toggleNetworkChoice()
       
   214 {
       
   215     bool visible = BtnNetLocal->isVisible();
       
   216     BtnNetLocal->setVisible(!visible);
       
   217     BtnNetOfficial->setVisible(!visible);
       
   218     if (visible)    BtnNet->setIcon(originalNetworkIcon);
       
   219     else            BtnNet->setIcon(disabledNetworkIcon);
       
   220 }