Explorar o código

Ton lautstärke verställbar

Kolja Strohm %!s(int64=5) %!d(string=hai) anos
pai
achega
759b62caf6

+ 5 - 0
KSGClient/NachLogin/Chat/ChatLeiste.cpp

@@ -8,6 +8,7 @@
 #include <ToolTip.h>
 #include <GSLDateiV.h>
 #include <Globals.h>
+#include <InitDatei.h>
 
 typedef GSL::GSLDateiV *( *GetGSLDatei )( );
 
@@ -97,8 +98,12 @@ void Chat::entfernen()
 
 void Chat::addNachricht( char *txt )
 {
+    int sound = userOptions->wertExistiert( "GUISound" ) ? *userOptions->zWert( "GUISound" ) : 100;
     if( msgSound )
+    {
+        msgSound->setVolume( (int)( ( sound / 100.0 ) * 0xFFFF ), (int)( ( sound / 100.0 ) * 0xFFFF ) );
         msgSound->playSound();
+    }
     Text * n = new Text( txt );
     verlauf->zTextRenderer()->textFormatieren( n, verlauf->getBreite() - 20 );
     if( n->getText()[ n->getLength() - 1 ] != '\n' )

+ 16 - 1
KSGClient/NachLogin/Chat/NachrichtenListe.cpp

@@ -11,6 +11,7 @@
 #include <ToolTip.h>
 #include <GSLDateiV.h>
 #include <Globals.h>
+#include <InitDatei.h>
 
 typedef GSL::GSLDateiV *( *GetGSLDatei )( );
 
@@ -730,18 +731,32 @@ NachrichtenListe::~NachrichtenListe()
 // nicht constant
 void NachrichtenListe::addNachricht( Text * titel, Text * nachricht, Text * positiv, Text * negativ, std::function<void()> posAk, std::function<void()> negAk )
 {
-    if( titel &&titel->hat( "Fehler" ) && errSound )
+    int sound = userOptions->wertExistiert( "GUISound" ) ? *userOptions->zWert( "GUISound" ) : 100;
+    if( titel && titel->hat( "Fehler" ) && errSound )
+    {
+        errSound->setVolume( (int)( ( sound / 100.0 ) * 0xFFFF ), (int)( ( sound / 100.0 ) * 0xFFFF ) );
         errSound->playSound();
+    }
     else if( msgSound )
+    {
+        msgSound->setVolume( (int)( ( sound / 100.0 ) * 0xFFFF ), (int)( ( sound / 100.0 ) * 0xFFFF ) );
         msgSound->playSound();
+    }
     nachrichtenListe->addNachricht( new Nachricht( schrift, titel, nachricht, positiv, negativ, posAk, negAk ) );
 }
 void NachrichtenListe::addNachricht( NLNachricht * nachricht )
 {
+    int sound = userOptions->wertExistiert( "GUISound" ) ? *userOptions->zWert( "GUISound" ) : 100;
     if( nachricht->zTitel() && nachricht->zTitel()->hat( "Fehler" ) && errSound )
+    {
+        errSound->setVolume( (int)( ( sound / 100.0 ) * 0xFFFF ), (int)( ( sound / 100.0 ) * 0xFFFF ) );
         errSound->playSound();
+    }
     else if( msgSound )
+    {
+        msgSound->setVolume( (int)( ( sound / 100.0 ) * 0xFFFF ), (int)( ( sound / 100.0 ) * 0xFFFF ) );
         msgSound->playSound();
+    }
     nachrichtenListe->addNachricht( nachricht );
 }
 

+ 3 - 0
KSGClient/NachLogin/Editor/Karte/Dateien/KEDEditor.cpp

@@ -4,6 +4,7 @@
 #include "../../../../Global/Variablen.h"
 #include <Model2D.h>
 #include <Globals.h>
+#include <InitDatei.h>
 
 // Inhalt der KEDBildSeite Klasse aus KEDEditor.h
 // Konstruktor
@@ -645,6 +646,8 @@ void KEDSoundSeite::setSound( GSL::GSLSoundV * b )
         sound->release();
     }
     sound = b;
+    int vol = userOptions->wertExistiert( "GUISound" ) ? *userOptions->zWert( "GUISound" ) : 100;
+    sound->setVolume( (int)( ( vol / 100.0 ) * 0xFFFF ), (int)( ( vol / 100.0 ) * 0xFFFF ) );
     sound->playSound();
 }
 

+ 14 - 3
KSGClient/NachLogin/Einstellungen/Einstellungen.cpp

@@ -55,6 +55,11 @@ Einstellungen::Einstellungen( Schrift *zSchrift, Fenster *zF )
     maxFPS = initTextFeld( 5, 70, 50, 20, zSchrift, TextFeld::Style::TextFeld, userOptions->wertExistiert( "MaxFPS" ) ? userOptions->zWert( "MaxFPS" )->getText() : "30" );
     maxFPS->setTastaturEreignis( _nurNummernTE );
     f->addMember( maxFPS->getThis() );
+    TextFeld *gst = initTextFeld( 5, 95, 200, 20, zSchrift, TextFeld::Style::Text, "GUI Lautstärke (0 bis 100)" );
+    f->addMember( gst );
+    guiSound = initTextFeld( 5, 115, 50, 20, zSchrift, TextFeld::Style::TextFeld, userOptions->wertExistiert( "GUISound" ) ? userOptions->zWert( "GUISound" )->getText() : "100" );
+    guiSound->setTastaturEreignis( _nurNummernTE );
+    f->addMember( guiSound->getThis() );
 	ok = initKnopf( 390, 450, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Ok" );
 	ok->setMausEreignisParameter( this );
 	ok->setMausEreignis( einstellungenOkME );
@@ -70,6 +75,7 @@ Einstellungen::Einstellungen( Schrift *zSchrift, Fenster *zF )
 Einstellungen::~Einstellungen()
 {
     maxFPS->release();
+    guiSound->release();
 	f->release();
 	ok->release();
 }
@@ -91,18 +97,23 @@ bool Einstellungen::okME( MausEreignis &me )
 {
 	if( me.id == ME_RLinks )
 	{
-		f->removeStyle( Fenster::Style::Sichtbar );
         int fps = *maxFPS->zText();
-        if( fps > 0 )
+        int sound = *guiSound->zText();
+        if( fps > 0 && sound >= 0 && sound <= 100 )
         {
+            f->removeStyle( Fenster::Style::Sichtbar );
             hauptScreen->lock();
             if( !userOptions->wertExistiert( "MaxFPS" ) )
                 userOptions->addWert( "MaxFPS", maxFPS->zText()->getText() );
             else
                 userOptions->setWert( "MaxFPS", maxFPS->zText()->getText() );
+            if( !userOptions->wertExistiert( "GUISound" ) )
+                userOptions->addWert( "GUISound", guiSound->zText()->getText() );
+            else
+                userOptions->setWert( "GUISound", guiSound->zText()->getText() );
             hauptScreen->unlock();
+            userOptions->speichern();
         }
-        userOptions->speichern();
 	}
 	return 1;
 }

+ 1 - 0
KSGClient/NachLogin/Einstellungen/Einstellungen.h

@@ -12,6 +12,7 @@ private:
 	Fenster *f;
 	Knopf *ok;
     TextFeld *maxFPS;
+    TextFeld *guiSound;
 	int ref;
 
 public: