123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- #include "Einstellungen.h"
- #include <GraphicsApi.h>
- #include <InitDatei.h>
- #include <MausEreignis.h>
- #include "../../Global/Initialisierung.h"
- #include "../../Global/Variablen.h"
- // Inhalt der Einstellungen Klasse aus Einstellungen.h
- // Konstruktor
- Einstellungen::Einstellungen(Fenster* zF)
- : ReferenceCounter()
- {
- f = initFenster(zF->getBreite() / 2 - 250,
- zF->getHeight() / 2 - 250,
- 500,
- 500,
- 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,
- TextFeld::Style::Text,
- "Grafik Engine (Neustart erforderlich)");
- f->addMember(gat);
- AuswahlBox* graphicAPI = initAuswahlBox(5,
- 25,
- 100,
- 20,
- 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) {
- userOptions->addWert("GraphicAPI", "BEST");
- 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, TextFeld::Style::Text, "Maximale FPS");
- f->addMember(mft);
- maxFPS = initTextFeld(5,
- 70,
- 50,
- 20,
- TextFeld::Style::TextFeld,
- userOptions->wertExistiert("MaxFPS")
- ? userOptions->zWert("MaxFPS")->getText()
- : "30");
- maxFPS->setTastaturEreignis(_nurNummernTE);
- f->addMember(dynamic_cast<Zeichnung*>(maxFPS->getThis()));
- TextFeld* gst = initTextFeld(
- 5, 95, 200, 20, TextFeld::Style::Text, "GUI Lautstärke (0 bis 100)");
- f->addMember(gst);
- guiSound = initTextFeld(5,
- 115,
- 50,
- 20,
- TextFeld::Style::TextFeld,
- userOptions->wertExistiert("GUISound")
- ? userOptions->zWert("GUISound")->getText()
- : "100");
- guiSound->setTastaturEreignis(_nurNummernTE);
- f->addMember(dynamic_cast<Zeichnung*>(guiSound->getThis()));
- TextFeld* mt = initTextFeld(255,
- 5,
- 200,
- 20,
- TextFeld::Style::Text,
- "Monitor (Neustart erforderlich)");
- f->addMember(mt);
- AuswahlBox* monitorAuswahl = initAuswahlBox(255,
- 25,
- 200,
- 20,
- AuswahlBox::Style::Normal | AuswahlBox::Style::Hintergrund,
- {});
- Monitor m = getMonitor(0);
- int index = 0;
- do
- {
- monitorAuswahl->addEintrag(Text("Monitor ") + ++index + " (" + m.breite
- + "x" + m.height + ")");
- m = getMonitor(index);
- } while (m.existiert);
- if (userOptions->wertExistiert("Monitor"))
- monitorAuswahl->setAuswahl((int)*userOptions->zWert("Monitor"));
- monitorAuswahl->setEventAktion(
- [this](void* p, AuswahlBox* b, int unused, int auswahl) {
- if (!userOptions->wertExistiert("Monitor"))
- userOptions->addWert("Monitor", Text(auswahl));
- else
- userOptions->setWert("Monitor", Text(auswahl));
- Monitor m = getMonitor(auswahl);
- if (!userOptions->wertExistiert("ScreenWidth"))
- userOptions->addWert("ScreenWidth", Text(m.breite));
- else
- userOptions->setWert("ScreenWidth", Text(m.breite));
- if (!userOptions->wertExistiert("ScreenWidth"))
- userOptions->addWert("ScreenHeight", Text(m.height));
- else
- userOptions->setWert("ScreenHeight", Text(m.height));
- breite->setText(Text(m.breite));
- height->setText(Text(m.height));
- });
- TextFeld* at = initTextFeld(255,
- 50,
- 200,
- 20,
- TextFeld::Style::Text,
- "Auflösung (Neustart erforderlich)");
- f->addMember(at);
- breite = initTextFeld(255,
- 70,
- 50,
- 20,
- TextFeld::Style::TextFeld,
- userOptions->wertExistiert("ScreenWidth")
- ? *userOptions->zWert("ScreenWidth")
- : Text(getMonitor(userOptions->wertExistiert("Monitor")
- ? (int)*userOptions->zWert("Monitor")
- : 0)
- .breite));
- height = initTextFeld(312,
- 70,
- 50,
- 20,
- TextFeld::Style::TextFeld,
- userOptions->wertExistiert("ScreenHeight")
- ? *userOptions->zWert("ScreenHeight")
- : Text(getMonitor(userOptions->wertExistiert("Monitor")
- ? (int)*userOptions->zWert("Monitor")
- : 0)
- .height));
- breite->setTastaturEreignis(_nurNummernTE);
- height->setTastaturEreignis(_nurNummernTE);
- f->addMember(dynamic_cast<Zeichnung*>(breite->getThis()));
- f->addMember(initTextFeld(305, 70, 5, 20, TextFeld::Style::Text, "x"));
- f->addMember(dynamic_cast<Zeichnung*>(height->getThis()));
- ok = initKnopf(390, 450, 100, 20, Knopf::Style::Sichtbar, "Ok");
- ok->setMausEreignisParameter(this);
- ok->setMausEreignis(einstellungenOkME);
- f->addMember(dynamic_cast<Zeichnung*>(ok->getThis()));
- // add AuswahlBoxen
- f->addMember(graphicAPI);
- f->addMember(monitorAuswahl);
- zF->addMember(dynamic_cast<Zeichnung*>(f->getThis()));
- }
- // Destruktor
- Einstellungen::~Einstellungen()
- {
- maxFPS->release();
- guiSound->release();
- breite->release();
- height->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 = (int)*maxFPS->zText();
- int sound = (int)*guiSound->zText();
- int wi = (int)*breite->zText();
- int hi = (int)*height->zText();
- if (fps > 0 && sound >= 0 && sound <= 100 && wi > 0 && hi > 0)
- {
- f->removeStyle(Fenster::Style::Sichtbar);
- uiFactory.initParam.bildschirm->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());
- if (!userOptions->wertExistiert("ScreenWidth"))
- userOptions->addWert("ScreenWidth", Text(wi));
- else
- userOptions->setWert("ScreenWidth", Text(wi));
- if (!userOptions->wertExistiert("ScreenHeight"))
- userOptions->addWert("ScreenHeight", Text(hi));
- else
- userOptions->setWert("ScreenHeight", Text(hi));
- uiFactory.initParam.bildschirm->unlock();
- userOptions->speichern();
- }
- }
- return 1;
- }
- // 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);
- }
|