File indexing completed on 2022-09-27 13:19:23

0001 /*
0002     SPDX-FileCopyrightText: 1998-2001 Andreas Zehender <az@azweb.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KSPACEDUEL_DIALOGS_H
0008 #define KSPACEDUEL_DIALOGS_H
0009 
0010 class QComboBox;
0011 class QTabWidget;
0012 class QSlider;
0013 class QLCDNumber;
0014 
0015 #include <KConfigDialog>
0016 
0017 #include "defines.h"
0018 #include "structs.h"
0019 
0020 
0021 class ConfigSetup:public QWidget
0022 {
0023    Q_OBJECT
0024 public:
0025    explicit ConfigSetup(SConfig *custom,QWidget *parent = nullptr);
0026 
0027    bool hasChanged();
0028    bool isDefault();
0029    void updateSettings();
0030    void updateWidgets();
0031    void updateWidgetsDefault();
0032 
0033 Q_SIGNALS:
0034    void changed();
0035 
0036 protected Q_SLOTS:
0037    void configSelected(int num);
0038    void sliderChanged(int val);
0039 protected:   
0040    void valueChanged(int ednum,int val);
0041    void valueChanged(int ednum,double val);
0042    void displayConfig(const SConfig &cfg);
0043    void setValue(int ednum,int val);
0044    void setValue(int ednum,double val);
0045    void setValue(int ednum,unsigned val);
0046 private:
0047    enum {EditGamespeed=0,
0048          EditShotSpeed,EditShotEnergyNeed,EditMaxBullets,EditBulletDamage,
0049          EditBulletLifeTime,EditBulletReloadTime,
0050          EditMineFuel,EditMineEnergyNeed,EditMineActivateTime,
0051          EditMineDamage,EditMaxMines,EditMineReloadTime,
0052          EditAcc,EditEnergyNeed,EditRotationSpeed,
0053          EditRotationEnergyNeed,EditShipDamage,
0054          EditSunEnergy,EditGravity,
0055          EditPosX,EditPosY,EditVelX,EditVelY,
0056          EditPowerupRefreshTime,EditPowerupLifeTime,
0057          EditPowerupEnergyAmount,EditPowerupShieldAmount,
0058          EditNum};
0059    enum {TabGeneral=0,TabBullet,TabMine,
0060          TabShip,TabSun,TabStart,TabPowerups,TabNum};
0061    enum Type {VarInt,VarFloat};
0062    
0063    static KLazyLocalizedString LabelName[EditNum];
0064 
0065    static int Parent[EditNum];
0066    static int Position[EditNum];
0067    static const char *TabName[TabNum];
0068    static double EditVal[EditNum][3];
0069    static int EditDiv[EditNum];
0070    static Type VarType[EditNum];
0071  
0072    QTabWidget *tabs;
0073 
0074    QSlider *slider[EditNum];
0075    QLCDNumber *value[EditNum];
0076    
0077    QComboBox *configCombo;
0078    SConfig *customConfig,config;
0079    
0080    int selectedConfig;
0081 };
0082 
0083 class SettingsDialog : public KConfigDialog
0084 {
0085         Q_OBJECT
0086 public:
0087         explicit SettingsDialog(SConfig *customConfig, QWidget *parent = nullptr, const char *name = nullptr);
0088         ~SettingsDialog() override;
0089 
0090 Q_SIGNALS:
0091         void settingsUpdated();
0092 
0093 private Q_SLOTS:
0094         void updateWidgets() override;
0095         void updateWidgetsDefault() override;
0096         void updateSettings() override;
0097                                         
0098 private:
0099         bool hasChanged() override;
0100         bool isDefault() override;
0101 
0102 private:
0103         ConfigSetup* cs;
0104 };
0105 
0106 #endif // KSPACEDUEL_DIALOGS_H