Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions libs/s25main/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void Settings::LoadIngameDefaults()
}

///////////////////////////////////////////////////////////////////////////////
// Routine zum Laden der Konfiguration
// Routine for loading the configuration
void Settings::Load()
{
libsiedler2::Archiv settings;
Expand All @@ -201,13 +201,13 @@ void Settings::Load()
const libsiedler2::ArchivItem_Ini* iniAddons =
static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("addons"));

// ist eine der Kategorien nicht vorhanden?
// Is one of the categories missing?
if(!iniGlobal || !iniVideo || !iniLanguage || !iniDriver || !iniSound || !iniLobby || !iniServer || !iniProxy
|| !iniInterface || !iniAddons)
{
throw std::runtime_error("Missing section");
}
// stimmt die Settingsversion?
// Is the settings version correct?
if(iniGlobal->getValue("version", 0) != VERSION)
throw std::runtime_error("Wrong version");

Expand Down Expand Up @@ -259,7 +259,7 @@ void Settings::Load()
sound.musicVolume = iniSound->getIntValue("musik_volume");
sound.effectsEnabled = iniSound->getBoolValue("effekte");
sound.effectsVolume = iniSound->getIntValue("effekte_volume");
sound.birdsEnabled = iniSound->getBoolValue("bird_sounds");
sound.birdsEnabled = iniSound->getValue("bird_sounds", true);
sound.playlist = iniSound->getValue("playlist");
// }

Expand Down Expand Up @@ -295,14 +295,14 @@ void Settings::Load()
proxy.type = ProxyType(iniProxy->getIntValue("typ"));
// }

// leere proxyadresse deaktiviert proxy komplett
// deaktivierter proxy entfernt proxyadresse
// Empty proxy address completely disables proxy.
// Disabled proxy removes proxy address.
if(proxy.hostname.empty() || (proxy.type != ProxyType::Socks4 && proxy.type != ProxyType::Socks5))
{
proxy.type = ProxyType::None;
proxy.hostname.clear();
}
// aktivierter Socks v4 deaktiviert ipv6
// Enabled Socks v4 disables IPv6
else if(proxy.type == ProxyType::Socks4 && server.ipv6)
server.ipv6 = false;

Expand Down Expand Up @@ -382,7 +382,7 @@ void Settings::LoadIngame()
}

///////////////////////////////////////////////////////////////////////////////
// Routine zum Speichern der Konfiguration
// Routine for saving the configuration
void Settings::Save()
{
libsiedler2::Archiv settings;
Expand All @@ -401,7 +401,7 @@ void Settings::Save()
libsiedler2::ArchivItem_Ini* iniInterface = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("interface"));
libsiedler2::ArchivItem_Ini* iniAddons = static_cast<libsiedler2::ArchivItem_Ini*>(settings.find("addons"));

// ist eine der Kategorien nicht vorhanden?
// Is one of the categories missing?
RTTR_Assert(iniGlobal && iniVideo && iniLanguage && iniDriver && iniSound && iniLobby && iniServer && iniProxy
&& iniInterface && iniAddons);

Expand Down
20 changes: 10 additions & 10 deletions libs/s25main/desktops/dskOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0))
ipv6->AddTextButton(ID_btOn, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, _("IPv6"), NormalFont);
ipv6->AddTextButton(ID_btOff, curPos + ctrlOffset2, ctrlSize, TextureColor::Grey, _("IPv4"), NormalFont);
ipv6->SetSelection(SETTINGS.server.ipv6);
// ipv6-feld ggf (de-)aktivieren
// Enable/disable the IPv6 field if necessary
ipv6->GetCtrl<ctrlButton>(1)->SetEnabled(SETTINGS.proxy.type != ProxyType::Socks5); //-V807
curPos.y += rowHeight + sectionSpacingCommon;

// Proxyserver
// Proxy server
groupCommon->AddText(ID_txtProxy, curPos, _("Proxyserver:"), COLOR_YELLOW, FontStyle{}, NormalFont);
ctrlEdit* proxy = groupCommon->AddEdit(ID_edtProxy, curPos + ctrlOffset, ctrlSize, TextureColor::Grey, NormalFont);
proxy->SetText(SETTINGS.proxy.hostname);
Expand All @@ -254,7 +254,7 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0))
upnp->SetSelection(SETTINGS.global.use_upnp);
curPos.y += rowHeight;

// Proxytyp
// Proxy type
groupCommon->AddText(ID_txtProxyType, curPos, _("Proxytyp:"), COLOR_YELLOW, FontStyle{}, NormalFont);
combo =
groupCommon->AddComboBox(ID_cbProxyType, curPos + ctrlOffset, ctrlSizeLarge, TextureColor::Grey, NormalFont, 100);
Expand Down Expand Up @@ -404,7 +404,7 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0))
combo->SetSelection(combo->GetNumItems() - 1);
}

// "Allgemein" auswählen
// Select "General"
mainGroup = GetCtrl<ctrlOptionGroup>(ID_grpOptions);
mainGroup->SetSelection(ID_btCommon, true);

Expand All @@ -413,7 +413,7 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0))

loadVideoModes();

// Und zu der Combobox hinzufügen
// and add to the combo box
ctrlComboBox& cbVideoModes = *groupGraphics->GetCtrl<ctrlComboBox>(ID_cbResolution);
for(const auto& videoMode : video_modes)
{
Expand All @@ -428,15 +428,15 @@ dskOptions::dskOptions() : Desktop(LOADER.GetImageN("setup013", 0))

cbVideoModes.AddString(str.str());

// Ist das die aktuelle Auflösung? Dann selektieren
// Select, if this is the current resolution
if(videoMode == SETTINGS.video.fullscreenSize) //-V807
cbVideoModes.SetSelection(cbVideoModes.GetNumItems() - 1);
}

// "Vollbild" setzen
// Set "Fullscreen"
groupGraphics->GetCtrl<ctrlOptionGroup>(ID_grpFullscreen)->SetSelection(SETTINGS.video.fullscreen); //-V807

// "Limit Framerate" füllen
// Fill "Limit Framerate"
auto* cbFrameRate = groupGraphics->GetCtrl<ctrlComboBox>(ID_cbFramerate);
if(VIDEODRIVER.HasVSync())
cbFrameRate->AddString(_("Dynamic (Limits to display refresh rate, works with most drivers)"));
Expand Down Expand Up @@ -520,7 +520,7 @@ void dskOptions::Msg_Group_ComboSelectItem(const unsigned group_id, const unsign
case 2: SETTINGS.proxy.type = ProxyType::Socks5; break;
}

// ipv6 gleich sichtbar deaktivieren
// Disable IPv6 visually
if(SETTINGS.proxy.type == ProxyType::Socks4 && SETTINGS.server.ipv6)
{
GetCtrl<ctrlGroup>(ID_grpCommon)->GetCtrl<ctrlOptionGroup>(ID_grpIpv6)->SetSelection(0);
Expand Down Expand Up @@ -625,7 +625,7 @@ void dskOptions::Msg_ButtonClick(const unsigned ctrl_id)
{
auto* groupCommon = GetCtrl<ctrlGroup>(ID_grpCommon);

// Name abspeichern
// Save the name
SETTINGS.lobby.name = groupCommon->GetCtrl<ctrlEdit>(ID_edtName)->GetText();
if(!validatePort(groupCommon->GetCtrl<ctrlEdit>(ID_edtPort)->GetText(), SETTINGS.server.localPort))
return;
Expand Down
29 changes: 15 additions & 14 deletions libs/s25main/ingameWindows/iwOptionsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "iwTextfile.h"
#include "ogl/FontStyle.h"
#include "gameData/const_gui_ids.h"
#include "controls/ctrlCheck.h"

namespace {
enum
Expand Down Expand Up @@ -51,7 +52,7 @@ iwOptionsWindow::iwOptionsWindow(SoundManager& soundManager)
LOADER.GetImageN("resource", 41)),
soundManager(soundManager)
{
// Der Soldat oben
// The soldier on top
AddImage(ID_imgSoldier, DrawPoint(150, 36), LOADER.GetImageN("io", 30));

AddText(ID_txtRttr, DrawPoint(150, 60), "Return To The Roots", COLOR_YELLOW, FontStyle::CENTER, NormalFont);
Expand All @@ -70,37 +71,37 @@ iwOptionsWindow::iwOptionsWindow(SoundManager& soundManager)
AddImageButton(ID_btReadme, DrawPoint(35, 160), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 79));
AddText(ID_txtReadme, DrawPoint(85, 180), _("Load 'ReadMe' file"), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont);

// "Spiel laden!"
// "Load game!"
// TODO: Implement
// AddImageButton( 8, DrawPoint(35, 210), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 48));
// AddText(9, DrawPoint(85, 230), _("Load game!"), COLOR_YELLOW, 0 | FontStyle::BOTTOM, NormalFont);

// "Spiel speichern!"
// "Save game!"
// TODO: Move back down to y=250 (Button) 270 (Text) after Load button is implemented
AddImageButton(ID_btSave, DrawPoint(35, 230), Extent(35, 35), TextureColor::Green2, LOADER.GetImageN("io", 47));
AddText(ID_txtSave, DrawPoint(85, 255), _("Save game!"), COLOR_YELLOW, FontStyle::BOTTOM, NormalFont);

// Geräusche an/aus
// Sound on/off
AddImageButton(ID_btSoundEffects, DrawPoint(35, 300), Extent(35, 35), TextureColor::Green2,
LOADER.GetImageN("io", 114 + !SETTINGS.sound.effectsEnabled)); //-V807

// Musik an/aus
AddImageButton(ID_btMusic, DrawPoint(35, 371), Extent(35, 35), TextureColor::Green2,
LOADER.GetImageN("io", 116 + !SETTINGS.sound.musicEnabled));

// Geräuschlautstärke
// Sound volume
AddProgress(ID_pgEffectVol, DrawPoint(100, 306), Extent(160, 22), TextureColor::Green2, 139, 138, 100)
->SetPosition((SETTINGS.sound.effectsVolume * 100) / 255);

// Vogelgeräusche an/aus
AddCheckBox(ID_cpBirdSounds, DrawPoint(100, 342), Extent(160, 22), TextureColor::Green2, _("Bird sounds"), NormalFont, false);
// Bird sounds on/off
AddCheckBox(ID_cpBirdSounds, DrawPoint(100, 342), Extent(160, 22), TextureColor::Green2, _("Bird sounds"), NormalFont, false)
->setChecked(SETTINGS.sound.birdsEnabled);

// Music on/off
AddImageButton(ID_btMusic, DrawPoint(35, 371), Extent(35, 35), TextureColor::Green2,
LOADER.GetImageN("io", 116 + !SETTINGS.sound.musicEnabled));

// Musiklautstärke
// Music volume
AddProgress(ID_pgMusicVol, DrawPoint(100, 377), Extent(160, 22), TextureColor::Green2, 139, 138, 100)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the spacing of the progress bars, checkbox and button is even. Can you use a similar pattern to the desktop: constexpr Extent ctrlSize(160, 22);, DrawPoint pos = ..., and pos.y += ctrlSize.y + spacingY and the use pos for the position?

The 2 buttons for enable/disable of music&effects would then need to be relative

While the current approach works with more controls added it becomes harder to reason if they are all placed "correctly".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With "the desktops" you mean the mechanism at for example my already touched libs/s25main/desktops/dskOptions.cpp? This would be really better indeed, due it was way easier for me to add my changes there then in the in-game menu.

I could try this, but I would need some time to implement the same principle to this menu. I'm not very familiar with C++ actually. 😁 I will let you know. 💪

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly. And you were familiar enough to do this change, so don't worry! :-)

You don't need to do this for this PR, just let me know if you are up to it and I'll wait before merging to avoid introducing this change just to change it again for a "better" solution.

If you need any help feel free to ask here, show intermediate results if that helps you question.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thx, I will try, yes pls wait, I let you know 💪

->SetPosition((SETTINGS.sound.musicVolume * 100) / 255);

AddTextButton(ID_btMusicPlayer, DrawPoint(100, 413), Extent(160, 22), TextureColor::Green2, _("Music player"),
NormalFont);
AddTextButton(ID_btMusicPlayer, DrawPoint(100, 413), Extent(160, 22), TextureColor::Green2, _("Music player"), NormalFont);
AddTextButton(ID_btAdvanced, DrawPoint(67, 442), Extent(168, 24), TextureColor::Green2, _("Advanced"), NormalFont);
AddTextButton(ID_btSurrender, DrawPoint(67, 473), Extent(168, 24), TextureColor::Red1, _("Surrender"), NormalFont);
AddTextButton(ID_btEndGame, DrawPoint(67, 504), Extent(168, 24), TextureColor::Red1, _("End game"), NormalFont);
Expand Down
Loading