123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- #include "Einstellungen.h"
- #include <MausEreignis.h>
- #include <GraphicsApi.h>
- #include <InitDatei.h>
- #include "../../Global/Variablen.h"
- #include "../../Global/Initialisierung.h"
- // Inhalt der Einstellungen Klasse aus Einstellungen.h
- // Konstruktor
- Einstellungen::Einstellungen( Schrift *zSchrift, Fenster *zF )
- {
- f = initFenster( zF->getBreite() / 2 - 250, zF->getHeight() / 2 - 250, 500, 500, zSchrift,
- Fenster::Style::normal | Fenster::Style::BodyHAlpha | Fenster::Style::BodyHintergrund |
- Fenster::Style::TitelHintergrund | Fenster::Style::TitelHAlpha, "Einstellungen" );
- f->removeStyle( Fenster::Style::Sichtbar );
- f->setKBgFarbe( 0xe0000000 );
- f->setTBgFarbe( 0xe0000000 );
- f->setSBgFarbe( 0xF0000000 );
- f->setClosingMeParam( this );
- f->setClosingMe( einstellungenSchließenME );
- TextFeld *gat = initTextFeld( 5, 5, 300, 20, zSchrift, TextFeld::Style::Text, "Grafik Engine (Neustart erforderlich)" );
- f->addMember( gat );
- AuswahlBox *graphicAPI = initAuswahlBox( 5, 25, 100, 20, zSchrift, AuswahlBox::Style::Normal | AuswahlBox::Style::Hintergrund, { "Aktuellste", "DirectX 9" } );
- if( DirectX11::isAvailable() )
- graphicAPI->addEintrag( "DirectX 11" );
- if( DirectX12::isAvailable() )
- graphicAPI->addEintrag( "DirectX 12" );
- graphicAPI->setAuswahl( 0 );
- if( userOptions->wertExistiert( "GraphicAPI" ) && userOptions->zWert( "GraphicAPI" )->istGleich( "DX9" ) )
- graphicAPI->setAuswahl( 1 );
- if( userOptions->wertExistiert( "GraphicAPI" ) && userOptions->zWert( "GraphicAPI" )->istGleich( "DX11" ) )
- graphicAPI->setAuswahl( 2 );
- if( userOptions->wertExistiert( "GraphicAPI" ) && userOptions->zWert( "GraphicAPI" )->istGleich( "DX12" ) )
- graphicAPI->setAuswahl( 3 );
- graphicAPI->setEventAktion( [ this ]( void *p, AuswahlBox * b, int unused, int auswahl )
- {
- switch( auswahl )
- {
- case 1:
- userOptions->setWert( "GraphicAPI", "DX9" );
- break;
- case 2:
- userOptions->setWert( "GraphicAPI", "DX11" );
- break;
- case 3:
- userOptions->setWert( "GraphicAPI", "DX12" );
- break;
- default:
- userOptions->setWert( "GraphicAPI", "BEST" );
- break;
- }
- } );
- TextFeld *mft = initTextFeld( 5, 50, 200, 20, zSchrift, TextFeld::Style::Text, "Maximale FPS" );
- f->addMember( mft );
- 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 );
- f->addMember( ok->getThis() );
- // add AuswahlBoxen
- f->addMember( graphicAPI );
- zF->addMember( f->getThis() );
- ref = 1;
- }
- // Destruktor
- Einstellungen::~Einstellungen()
- {
- maxFPS->release();
- guiSound->release();
- f->release();
- ok->release();
- }
- // nicht constant
- void Einstellungen::setSichtbar()
- {
- f->setStyle( Fenster::Style::Sichtbar, f->hatStyleNicht( Fenster::Style::Sichtbar ) );
- }
- bool Einstellungen::closeME( MausEreignis &me )
- {
- if( me.id == ME_RLinks )
- f->removeStyle( Fenster::Style::Sichtbar );
- return 1;
- }
- bool Einstellungen::okME( MausEreignis &me )
- {
- if( me.id == ME_RLinks )
- {
- int fps = *maxFPS->zText();
- 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();
- }
- }
- return 1;
- }
- // Reference Counting
- Einstellungen *Einstellungen::getThis()
- {
- ref++;
- return this;
- }
- Einstellungen *Einstellungen::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
- // Ereignisse
- bool einstellungenSchließenME( void *p, void *obj, MausEreignis me )
- {
- if( !p )
- return 1;
- return ( (Einstellungen*)p )->closeME( me );
- }
- bool einstellungenOkME( void *p, void *obj, MausEreignis me )
- {
- if( !p )
- return 1;
- return ( (Einstellungen*)p )->okME( me );
- }
|