-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on virtual display mode support
Saving out display mode ratio of max res, and adding support for client to set resolution in response to window events
- Loading branch information
1 parent
2a059e0
commit 9df8d56
Showing
11 changed files
with
372 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,6 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
#include "pfPython/cyMisc.h" | ||
#include "pfPython/cyPythonInterface.h" | ||
|
||
|
||
#define MSG_LOADING_BAR | ||
|
||
// static hsVector3 gAbsDown(0,0,-1.f); | ||
|
@@ -221,6 +220,7 @@ plClient::~plClient() | |
plClient::SetInstance(nullptr); | ||
|
||
delete fPageMgr; | ||
delete fGraphicsIni; | ||
} | ||
|
||
template<typename T> | ||
|
@@ -443,6 +443,7 @@ bool plClient::InitPipeline(hsWindowHndl display, uint32_t devType) | |
|
||
hsG3DDeviceRecord *rec = (hsG3DDeviceRecord *)dmr.GetDevice(); | ||
|
||
#if !PLASMA_DISPLAY_INDEPENDENT_VIDEO_MODES | ||
if(!plPipeline::fInitialPipeParams.Windowed) | ||
{ | ||
// find our resolution if we're not in windowed mode | ||
|
@@ -467,6 +468,7 @@ bool plClient::InitPipeline(hsWindowHndl display, uint32_t devType) | |
ISetGraphicsDefaults(); | ||
} | ||
} | ||
#endif | ||
|
||
if(plPipeline::fInitialPipeParams.TextureQuality == -1) | ||
{ | ||
|
@@ -1900,6 +1902,47 @@ void plClient::ResizeDisplayDevice(int Width, int Height, bool Windowed) | |
IResizeNativeDisplayDevice(Width, Height, Windowed); | ||
} | ||
|
||
void plClient::SetDisplayOptions(int Width, int Height, bool Windowed) | ||
{ | ||
fGraphicsIni->readFile(); | ||
std::shared_ptr<hsIniEntry> entry = fGraphicsIni->findByCommand("Graphics.Windowed"); | ||
if (entry) { | ||
entry->setValue(0, Windowed ? "true" : "false"); | ||
} | ||
|
||
entry = fGraphicsIni->findByCommand("Graphics.OutputScale"); | ||
if (entry) { | ||
double scale = entry->getValue(0)->to_uint() / 100.0; | ||
Width *= scale; | ||
Height *= scale; | ||
} | ||
|
||
entry = fGraphicsIni->findByCommand("Graphics.Width"); | ||
if (entry) { | ||
entry->setValue(0, std::to_string(Width)); | ||
} | ||
entry = fGraphicsIni->findByCommand("Graphics.Height"); | ||
if (entry) { | ||
entry->setValue(0, std::to_string(Height)); | ||
} | ||
fGraphicsIni->writeFile(); | ||
|
||
FlushGraphicsOptions(); | ||
} | ||
|
||
void plClient::FlushGraphicsOptions() | ||
{ | ||
int Width = fGraphicsIni->findByCommand("Graphics.Width")->getValue(0)->to_int(); | ||
int Height = fGraphicsIni->findByCommand("Graphics.Height")->getValue(0)->to_int(); | ||
int ColorDepth = fGraphicsIni->findByCommand("Graphics.ColorDepth")->getValue(0)->to_int(); | ||
int NumAASamples = fGraphicsIni->findByCommand("Graphics.AntiAliasAmount")->getValue(0)->to_int(); | ||
int MaxAnisotropicSamples = fGraphicsIni->findByCommand("Graphics.AnisotropicLevel")->getValue(0)->to_int(); | ||
bool VSync = (fGraphicsIni->findByCommand("Graphics.EnableVSync")->getValue(0) == "true"); | ||
bool Windowed = (fGraphicsIni->findByCommand("Graphics.Windowed")->getValue(0) == "true"); | ||
|
||
ResetDisplayDevice(Width, Height, ColorDepth, Windowed, NumAASamples, MaxAnisotropicSamples); | ||
} | ||
|
||
void WriteBool(hsStream *stream, const char *name, bool on ) | ||
{ | ||
char command[256]; | ||
|
@@ -1998,6 +2041,8 @@ void plClient::IDetectAudioVideoSettings() | |
s.Close(); | ||
else | ||
IWriteDefaultGraphicsSettings(graphicsIniFile); | ||
|
||
fGraphicsIni = new hsIniFile(graphicsIniFile); | ||
} | ||
|
||
void plClient::IWriteDefaultAudioSettings(const plFileName& destFile) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
|
||
#include "HeadSpin.h" | ||
#include "hsBitVector.h" | ||
#include "hsIniHelper.h" | ||
#include "plFileSystem.h" | ||
|
||
#include <list> | ||
|
@@ -157,6 +158,8 @@ class plClient : public hsKeyedObject | |
|
||
plMessagePumpProc fMessagePumpProc; | ||
|
||
hsIniFile *fGraphicsIni; | ||
|
||
#ifndef PLASMA_EXTERNAL_RELEASE | ||
bool bPythonDebugConnected; | ||
#endif | ||
|
@@ -223,6 +226,7 @@ class plClient : public hsKeyedObject | |
void IResizeNativeDisplayDevice(int width, int height, bool windowed); | ||
void IChangeResolution(int width, int height); | ||
void IUpdateProgressIndicator(plOperationProgress* progress); | ||
void FlushGraphicsOptions(); | ||
|
||
public: | ||
|
||
|
@@ -310,6 +314,7 @@ class plClient : public hsKeyedObject | |
void SetMessagePumpProc(plMessagePumpProc proc) { fMessagePumpProc = proc; } | ||
void ResetDisplayDevice(int Width, int Height, int ColorDepth, bool Windowed, int NumAASamples, int MaxAnisotropicSamples, bool VSync = false); | ||
void ResizeDisplayDevice(int Width, int Height, bool Windowed); | ||
void SetDisplayOptions(int Width, int Height, bool Windowed); | ||
|
||
plAnimDebugList *fAnimDebugList; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// | ||
// hsIniHelper.cpp | ||
// CoreLib | ||
// | ||
// Created by Colin Cornaby on 8/29/22. | ||
// | ||
|
||
#include "hsIniHelper.h" | ||
#include "hsStringTokenizer.h" | ||
|
||
hsIniEntry::hsIniEntry(ST::string line): | ||
fCommand(), fComment() { | ||
if(line.size() == 0) { | ||
fType = kBlankLine; | ||
} else if(line[0] == '#') { | ||
fType = kComment; | ||
fComment = line.after_first('#'); | ||
} else if(line == "\n") { | ||
fType = kBlankLine; | ||
} else { | ||
fType = kCommandValue; | ||
hsStringTokenizer tokenizer = hsStringTokenizer(line.c_str(), " "); | ||
char *str; | ||
int i = 0; | ||
while((str = tokenizer.next())) { | ||
if (i==0) { | ||
fCommand = str; | ||
} else { | ||
fValues.push_back(str); | ||
} | ||
i++; | ||
} | ||
} | ||
} | ||
|
||
void hsIniEntry::setValue(size_t idx, ST::string value) { | ||
if (fValues.size() >= idx) { | ||
fValues[idx] = value; | ||
} else { | ||
for (int i=fValues.size(); i<idx; i++) { | ||
fValues.push_back(""); | ||
} | ||
fValues.push_back(value); | ||
} | ||
} | ||
|
||
std::optional<ST::string> hsIniEntry::getValue(size_t idx) { | ||
if (fValues.size() < idx) { | ||
return std::optional<ST::string>(); | ||
} else { | ||
return fValues[idx]; | ||
} | ||
} | ||
|
||
|
||
hsIniFile::hsIniFile(plFileName filename) { | ||
|
||
this->filename = filename; | ||
readFile(); | ||
} | ||
|
||
|
||
hsIniFile::hsIniFile(hsStream& stream) { | ||
readStream(stream); | ||
} | ||
|
||
void hsIniFile::readStream(hsStream& stream) { | ||
ST::string line; | ||
while(stream.ReadLn(line)) { | ||
std::shared_ptr<hsIniEntry> entry = std::make_shared<hsIniEntry>(line); | ||
fEntries.push_back(entry); | ||
} | ||
} | ||
|
||
void hsIniFile::writeFile() { | ||
hsAssert(filename.GetSize() > 0, "writeFile requires contructor with filename"); | ||
|
||
hsBufferedStream s; | ||
s.Open(filename, "w"); | ||
writeStream(s); | ||
s.Close(); | ||
} | ||
|
||
void hsIniFile::readFile() { | ||
hsAssert(filename.GetSize() > 0, "writeFile requires contructor with filename"); | ||
|
||
fEntries.clear(); | ||
|
||
hsBufferedStream s; | ||
s.Open(filename); | ||
readStream(s); | ||
s.Close(); | ||
} | ||
|
||
void hsIniFile::writeFile(plFileName filename) { | ||
hsBufferedStream s; | ||
s.Open(filename, "w"); | ||
writeStream(s); | ||
s.Close(); | ||
} | ||
|
||
void hsIniFile::writeStream(hsStream& stream) { | ||
for (std::shared_ptr<hsIniEntry> entry: fEntries) { | ||
switch (entry->fType) { | ||
case hsIniEntry::kBlankLine: | ||
stream.WriteSafeString("\n"); | ||
break; | ||
case hsIniEntry::kComment: | ||
stream.WriteSafeString("#" + entry.get()->fComment + "\n"); | ||
break; | ||
case hsIniEntry::kCommandValue: | ||
ST::string line = entry->fCommand; | ||
for (ST::string value: entry->fValues) { | ||
line += " " + value; | ||
} | ||
line += "\n"; | ||
stream.WriteString(line); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
std::shared_ptr<hsIniEntry> hsIniFile::findByCommand(ST::string command) { | ||
for (std::shared_ptr<hsIniEntry> entry: fEntries) { | ||
if(entry->fCommand == command) { | ||
return entry; | ||
} | ||
} | ||
return std::shared_ptr<hsIniEntry>(nullptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// hsIniHelper.hpp | ||
// CoreLib | ||
// | ||
// Created by Colin Cornaby on 8/29/22. | ||
// | ||
|
||
#ifndef hsIniHelper_hpp | ||
#define hsIniHelper_hpp | ||
|
||
#include <stdio.h> | ||
#include <string_theory/string> | ||
#include <vector> | ||
#include <optional> | ||
#include "plFileSystem.h" | ||
#include "hsStream.h" | ||
|
||
#endif /* hsIniHelper_hpp */ | ||
|
||
class hsIniFile; | ||
|
||
class hsIniEntry { | ||
friend hsIniFile; | ||
public: | ||
|
||
enum Type { | ||
kBlankLine = 0, | ||
kComment, | ||
kCommandValue | ||
}; | ||
|
||
Type fType; | ||
ST::string fCommand; | ||
ST::string fComment; | ||
std::vector<ST::string> fValues; | ||
void setValue(size_t idx, ST::string value); | ||
std::optional<ST::string> getValue(size_t idx); | ||
hsIniEntry(ST::string line); | ||
}; | ||
|
||
class hsIniFile { | ||
public: | ||
std::vector<std::shared_ptr<hsIniEntry>> fEntries; | ||
|
||
hsIniFile(plFileName filename); | ||
hsIniFile(hsStream& stream); | ||
void writeFile(plFileName filename); | ||
void writeFile(); | ||
void writeStream(hsStream& stream); | ||
std::shared_ptr<hsIniEntry> findByCommand(ST::string command); | ||
void readFile(); | ||
private: | ||
void readStream(hsStream& stream); | ||
plFileName filename; | ||
}; |
Oops, something went wrong.