QTfrontend/campaign.cpp
changeset 7201 dc17ffdf0702
child 7794 ab7b94c03bc9
equal deleted inserted replaced
7199:f329fbf1ffb4 7201:dc17ffdf0702
       
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    17  */
       
    18 
       
    19 #include <QDir>
       
    20 #include <QFile>
       
    21 #include <QTextStream>
       
    22 #include <QMessageBox>
       
    23 #include <QPushButton>
       
    24 #include <QListWidget>
       
    25 #include <QStackedLayout>
       
    26 #include <QLineEdit>
       
    27 #include <QLabel>
       
    28 #include <QRadioButton>
       
    29 #include <QSpinBox>
       
    30 #include <QCloseEvent>
       
    31 #include <QCheckBox>
       
    32 #include <QTextBrowser>
       
    33 #include <QAction>
       
    34 #include <QTimer>
       
    35 #include <QScrollBar>
       
    36 #include <QDataWidgetMapper>
       
    37 #include <QTableView>
       
    38 #include <QCryptographicHash>
       
    39 #include <QSignalMapper>
       
    40 #include <QShortcut>
       
    41 #include <QDesktopServices>
       
    42 #include <QInputDialog>
       
    43 #include <QPropertyAnimation>
       
    44 #include <QSettings>
       
    45 
       
    46 #include "campaign.h"
       
    47 #include "gameuiconfig.h"
       
    48 #include "hwconsts.h"
       
    49 #include "gamecfgwidget.h"
       
    50 #include "bgwidget.h"
       
    51 #include "mouseoverfilter.h"
       
    52 #include "tcpBase.h"
       
    53 
       
    54 #include "DataManager.h"
       
    55 
       
    56 extern QString campaign, campaignTeam;
       
    57 
       
    58 QStringList getCampMissionList(QString & campaign)
       
    59 {
       
    60     QSettings campfile(DataManager::instance().findFileForRead("Missions/Campaign/" + campaign + "/campaign.ini"), QSettings::IniFormat, 0);
       
    61     campfile.setIniCodec("UTF-8");
       
    62     unsigned int mNum = campfile.value("MissionNum", 0).toInt();
       
    63     
       
    64     QStringList missionList;
       
    65     for (unsigned int i = 0; i < mNum; i++)
       
    66     {
       
    67       missionList += campfile.value(QString("Mission %1/Name").arg(i + 1)).toString();
       
    68     }
       
    69     return missionList;
       
    70 }
       
    71   
       
    72 unsigned int getCampProgress(QString & teamName, QString & campName)
       
    73 {
       
    74     QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
       
    75     teamfile.setIniCodec("UTF-8");
       
    76     return teamfile.value("Campaign " + campName + "/Progress", 0).toInt();
       
    77 }
       
    78 
       
    79 QString getCampaignScript(QString campaign, unsigned int mNum)
       
    80 {
       
    81     QSettings campfile(DataManager::instance().findFileForRead("Missions/Campaign/" + campaign + "/campaign.ini"), QSettings::IniFormat, 0);
       
    82     campfile.setIniCodec("UTF-8");
       
    83     return campfile.value(QString("Mission %1/Script").arg(mNum)).toString();
       
    84 }
       
    85 
       
    86 
       
    87     
       
    88 
       
    89 
       
    90 
       
    91