Skip to content

Commit

Permalink
Add config variables for windowed width and height
Browse files Browse the repository at this point in the history
As suggested by @TheKins
  • Loading branch information
ArnoAnsems committed Nov 20, 2024
1 parent cc02b8f commit a666171
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
24 changes: 16 additions & 8 deletions src/Engine/ConfigurationSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ ConfigurationSettings::ConfigurationSettings() :
m_pathApocalypsev101("", "pathapocalypsev101", ""),
m_pathCatacomb3Dv122("", "pathcatacomb3dv122", ""),
m_cvarsString(
{
std::make_pair(CVarIdPathAbyssv113, &m_pathAbyssv113),
std::make_pair(CVarIdPathAbyssv124, &m_pathAbyssv124),
std::make_pair(CVarIdPathArmageddonv102, &m_pathArmageddonv102),
std::make_pair(CVarIdPathApocalypsev101, &m_pathApocalypsev101),
std::make_pair(CVarIdPathCatacomb3Dv122, &m_pathCatacomb3Dv122)
}),
{
std::make_pair(CVarIdPathAbyssv113, &m_pathAbyssv113),
std::make_pair(CVarIdPathAbyssv124, &m_pathAbyssv124),
std::make_pair(CVarIdPathArmageddonv102, &m_pathArmageddonv102),
std::make_pair(CVarIdPathApocalypsev101, &m_pathApocalypsev101),
std::make_pair(CVarIdPathCatacomb3Dv122, &m_pathCatacomb3Dv122)
}),
m_dummyCvarEnum("Dummy", "Dummy", { {"","",""} }, 0),
m_screenMode("Screen Mode", "screenmode",
{
Expand Down Expand Up @@ -140,11 +140,15 @@ ConfigurationSettings::ConfigurationSettings() :
m_fov("Field Of View (Y)", "fov", 20, 45, 25),
m_mouseSensitivity("Mouse Sensitiv.", "mouseSensitivity", 1, 20, 10),
m_turnSpeed("Turn Speed", "turnSpeed", 100, 250, 100),
m_windowedScreenWidth("Win. Screen Width", "WindowedScreenWidth", 320, 8192, 800),
m_windowedScreenHeight("Win. Screen Height", "WindowedScreenHeight", 200, 8192, 600),
m_cvarsInt(
{
std::make_pair(CVarIdFov, &m_fov),
std::make_pair(CVarIdMouseSensitivity, &m_mouseSensitivity),
std::make_pair(CVarIdTurnSpeed, &m_turnSpeed)
std::make_pair(CVarIdTurnSpeed, &m_turnSpeed),
std::make_pair(CVarIdWindowedScreenWidth, &m_windowedScreenWidth),
std::make_pair(CVarIdWindowedScreenHeight, &m_windowedScreenHeight)
})
{

Expand Down Expand Up @@ -186,6 +190,8 @@ void ConfigurationSettings::LoadFromFile(const fs::path& configurationFile)
DeserializeCVar(keyValuePairs, CVarIdFov);
DeserializeCVar(keyValuePairs, CVarIdScreenResolution);
DeserializeCVar(keyValuePairs, CVarIdCameraPosition);
DeserializeCVar(keyValuePairs, CVarIdWindowedScreenWidth);
DeserializeCVar(keyValuePairs, CVarIdWindowedScreenHeight);
DeserializeCVar(keyValuePairs, CVarIdSoundMode);
DeserializeCVar(keyValuePairs, CVarIdMusicMode);
DeserializeCVar(keyValuePairs, CVarIdMusicModeAdventureTrilogy);
Expand Down Expand Up @@ -250,6 +256,8 @@ void ConfigurationSettings::StoreToFile(const fs::path& configurationFile) const
SerializeCVar(file, CVarIdFov);
SerializeCVar(file, CVarIdAutoMapMode);
SerializeCVar(file, CVarIdCameraPosition);
SerializeCVar(file, CVarIdWindowedScreenWidth);
SerializeCVar(file, CVarIdWindowedScreenHeight);
file << "# Sound settings\n";
SerializeCVar(file, CVarIdSoundMode);
SerializeCVar(file, CVarIdMusicMode);
Expand Down
4 changes: 4 additions & 0 deletions src/Engine/ConfigurationSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ static constexpr uint8_t CVarIdMusicMode = 25;
static constexpr uint8_t CVarIdTextureFilter = 26;
static constexpr uint8_t CVarIdAspectRatio = 27;
static constexpr uint8_t CVarIdCameraPosition = 28;
static constexpr uint8_t CVarIdWindowedScreenWidth = 29;
static constexpr uint8_t CVarIdWindowedScreenHeight = 30;
static constexpr uint8_t CVarIdFov = 40;
static constexpr uint8_t CVarIdMouseSensitivity = 41;
static constexpr uint8_t CVarIdTurnSpeed = 42;
Expand Down Expand Up @@ -156,4 +158,6 @@ class ConfigurationSettings
ConsoleVariableInt m_fov;
ConsoleVariableInt m_mouseSensitivity;
ConsoleVariableInt m_turnSpeed;
ConsoleVariableInt m_windowedScreenWidth;
ConsoleVariableInt m_windowedScreenHeight;
};
6 changes: 4 additions & 2 deletions src/System/CatacombGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,16 @@ int main(int argc, char* argv[])
}

// Create Our OpenGL Window
CreateGLWindow(800, 600, 16, window, context);
const int windowedScreenWidth = config.GetCVarInt(CVarIdWindowedScreenWidth).GetValue();
const int windowedScreenHeight = config.GetCVarInt(CVarIdWindowedScreenHeight).GetValue();
CreateGLWindow(windowedScreenWidth, windowedScreenHeight, 16, window, context);

renderer = new RendererOpenGL();
renderer->Setup();
SetScreenMode(config.GetCVarEnum(CVarIdScreenMode).GetItemIndex(), window);

// Set Up Our Perspective GL Screen
ReSizeGLScene(renderer, 800, 600);
ReSizeGLScene(renderer, windowedScreenWidth, windowedScreenHeight);

Logging::Instance().AddLogMessage("Running on graphics adapter model " + renderer->GetGraphicsAdapterModel());
Logging::Instance().AddLogMessage("Running on " + renderer->GetGraphicsApiVersion());
Expand Down

0 comments on commit a666171

Please sign in to comment.