Skip to content

Commit

Permalink
[add]添加静音功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Realself-Ma authored Aug 23, 2020
1 parent 738e43f commit de4fc06
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
25 changes: 23 additions & 2 deletions Dungeon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Dungeon::Dungeon(QWidget *parent): QWidget(parent)
pre_floor=1;
MyPonit=0;
CmptorPoint=0;
CountDown=180;
CountDown=80;
NetModeStart=false;
MyWin=false;
dogFall=false;
Expand Down Expand Up @@ -960,6 +960,7 @@ void Dungeon::initialinfoWidget()
connect(menu->ReturnRooms,SIGNAL(clicked()),this,SLOT(ReturnRoomsPlay()));
connect(menu->Help,SIGNAL(clicked()),this,SLOT(HelpPlay()));
connect(help->Return,SIGNAL(clicked()),this,SLOT(HelpReturnPlay()));
connect(menu->music,SIGNAL(clicked()),this,SLOT(musicChangePlay()));

infoWidget->setMinimumSize(300,672);
infoWidget->setStyleSheet("color:white;border-image: url(:/interface/image/interface/infobg.png);");
Expand Down Expand Up @@ -1023,6 +1024,26 @@ void Dungeon::HelpReturnPlay()
{
help->hide();
}
void Dungeon::musicChangePlay()
{
music->musicChange=!music->musicChange;
if(music->musicChange==false)
{
music->InterfaceBGM->setVolume(0);
music->DungeonBGM->setVolume(0);
music->DungeonSound->setVolume(0);
music->FightSound->setVolume(0);
menu->music->setStyleSheet("border-image: url(:/info/image/information/music-off.png);");
}
else
{
music->InterfaceBGM->setVolume(50);
music->DungeonBGM->setVolume(50);
music->DungeonSound->setVolume(80);
music->FightSound->setVolume(80);
menu->music->setStyleSheet("border-image: url(:/info/image/information/music-on.png);");
}
}
void Dungeon::ShowFog()
{
for(int i=0;i<12;i++)
Expand Down Expand Up @@ -1172,7 +1193,7 @@ void Dungeon::NetModeCountDownRun()
NetMode_secondes->setText(QString::number(--CountDown));
if(CountDown<=0)
{
CountDown=180;
CountDown=80;
surface->sign->roomWidget->chatRoom->pkRequest();
NetModeCountDownTimer->stop();
}
Expand Down
1 change: 1 addition & 0 deletions Dungeon.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ private slots:
void ReturnRoomsPlay();//返回游戏房间
void HelpPlay();//帮助界面
void HelpReturnPlay();//帮助界面返回
void musicChangePlay();//打开/关闭音乐
void EnterDungeon();//角色名设置完成,进入地牢
void NetStart();
void pkStart();
Expand Down
4 changes: 4 additions & 0 deletions menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Menu::Menu(QWidget *parent) :
ReturnRooms=fac->CreateQPushButton(MenuWidget,200,200,120,30,"返回房间",button_style,fontLabel);
ReturnRooms->hide();
Help=fac->CreateQPushButton(MenuWidget,200,280,120,30,"帮助",button_style,fontLabel);

music=fac->CreateQPushButton(MenuWidget,300,40,30,30,"",
"border-image: url(:/info/image/information/music-on.png);");

}
void Menu::showEvent(QShowEvent *)
{
Expand Down
1 change: 1 addition & 0 deletions menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Menu: public QWidget
QPushButton *Continue;
QPushButton *ReturnRooms;
QPushButton *Help;
QPushButton *music;
bool MenuWinShow;
private:
Factory* fac;
Expand Down
2 changes: 1 addition & 1 deletion sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Sound::Sound(QWidget *parent) :
FightSoundTimer=new QTimer(this);
connect(FightSoundTimer,SIGNAL(timeout()),this,SLOT(CheckFightSoundstate()));


DungeonSoundTimer=new QTimer(this);
connect(DungeonSoundTimer,SIGNAL(timeout()),this,SLOT(SoundStop()));

musicChange=true;
}
void Sound::CheckInterfaceBGMstate()
{
Expand Down
1 change: 1 addition & 0 deletions sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Sound: public QWidget
QTimer *DungeonSoundTimer;
QTimer *InterfaceBGMTimer;
QTimer *DungeonBGMTimer;
bool musicChange;
public:
void SoundPlay(int CurrentIndex);
private:
Expand Down
2 changes: 2 additions & 0 deletions sources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<file>image/information/房间.png</file>
<file>image/information/MarioLeft.png</file>
<file>image/information/MarioRight.png</file>
<file>image/information/music-off.png</file>
<file>image/information/music-on.png</file>
</qresource>
<qresource prefix="/interface">
<file>image/interface/labelbg.png</file>
Expand Down

0 comments on commit de4fc06

Please sign in to comment.