Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new DynamicCamMap checkbox. #1572

Merged
merged 4 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions Scripts/Python/plasma/Plasma.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,10 @@ def PtStartScreenCapture(selfKey,width=800,height=600):
"""Starts a capture of the screen"""
pass

def PtSupportsPlanarReflections() -> bool:
"""Returns if planar reflections are supported"""
...
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency with the rest of the file, and because this isn't a .pyi file:

Suggested change
...
pass

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the way that I've been doing all the rest of the new/updated API functions to ease the (eventual? hopeful?) transition to pyi. Example:

def PtYesNoDialog(cb: Union[None, ptKey, Callable], message: str, /, dialogType: int = PtConfirmationType.YesNo) -> None:
"""This will display a confirmation dialog to the user with the text `message`. This dialog
_has_ to be answered by the user, and their answer will be returned in a Notify message
or callback given by `cb`."""
...

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, alright then - I guess I never noticed any of those yet. Yes, it would be nice to convert these to proper .pyi files at some point.


def PtToggleAvatarClickability(on):
"""Turns on and off our avatar's clickability"""
pass
Expand Down
10 changes: 6 additions & 4 deletions Scripts/Python/xIniDisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@
kGraphicsShadows = "Graphics.Shadow.Enable"
kGraphicsVerticalSync = "Graphics.EnableVSync"
kGraphicsShadowQuality = "Graphics.Shadow.VisibleDistance"
kGraphicsDynamicReflections = "Graphics.EnablePlanarReflections"
Copy link
Contributor

Choose a reason for hiding this comment

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

For anyone else wondering: this console command has already existed since forever.


CmdList = [kGraphicsWidth, kGraphicsHeight, kGraphicsColorDepth, kGraphicsWindowed, kGraphicsTextureQuality, kGraphicsAntiAliasLevel, kGraphicsAnisotropicLevel, kGraphicsQualityLevel, kGraphicsShadows, kGraphicsVerticalSync, kGraphicsShadowQuality]
DefaultsList = ["800", "600", "32", "false", "2", "0", "0", "2", "true", "false", "0"]
CmdList = [kGraphicsWidth, kGraphicsHeight, kGraphicsColorDepth, kGraphicsWindowed, kGraphicsTextureQuality, kGraphicsAntiAliasLevel, kGraphicsAnisotropicLevel, kGraphicsQualityLevel, kGraphicsShadows, kGraphicsVerticalSync, kGraphicsShadowQuality, kGraphicsDynamicReflections]
DefaultsList = ["800", "600", "32", "false", "2", "0", "0", "2", "true", "false", "0", "1"]

def ConstructFilenameAndPath():
global gFilenameAndPath
Expand Down Expand Up @@ -105,6 +106,7 @@ def ReadIni():
gIniFile.addEntry(kGraphicsShadows + " true")
gIniFile.addEntry(kGraphicsVerticalSync + " false")
gIniFile.addEntry(kGraphicsShadowQuality + " 0")
gIniFile.addEntry(kGraphicsDynamicReflections + " 1")
gIniFile.writeFile(gFilenameAndPath)

else:
Expand All @@ -120,9 +122,9 @@ def ReadIni():
ConstructFilenameAndPath()
gIniFile.writeFile(gFilenameAndPath)

def SetGraphicsOptions(width, heigth, colordepth, windowed, texquality, aaLevel, anisoLevel, qualityLevel, useShadows, vsync, shadowqual):
def SetGraphicsOptions(width, heigth, colordepth, windowed, texquality, aaLevel, anisoLevel, qualityLevel, useShadows, vsync, shadowqual, dynRefl):
if gIniFile:
paramList = [width, heigth, colordepth, windowed, texquality, aaLevel, anisoLevel, qualityLevel, useShadows, vsync, shadowqual]
paramList = [width, heigth, colordepth, windowed, texquality, aaLevel, anisoLevel, qualityLevel, useShadows, vsync, shadowqual, dynRefl]
for idx in range(len(CmdList)):
entry,junk = gIniFile.findByCommand(CmdList[idx])
val = str(paramList[idx])
Expand Down
144 changes: 22 additions & 122 deletions Scripts/Python/xOptionsMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
AdvGameSettingDlg = ptAttribGUIDialog(10, "The Adv Game Settings dialog")
ResetWarnDlg = ptAttribGUIDialog(11, "The Reset Warning dialog")
ReleaseNotesDlg = ptAttribGUIDialog(12, "Release Notes dialog")
respDisableItems = ptAttribResponder(13, "resp: Disable Items", ["enableRes", "disableRes", "enableWindow", "disableWindow", "enableEAX", "disableEAX", "enableGamma", "disableGamma"])
respDisableItems = ptAttribResponder(13, "resp: Disable Items", ["enableRes", "disableRes", "enableWindow", "disableWindow", "enableEAX", "disableEAX", "enableGamma", "disableGamma", "enableDynRefl", "disableDynRefl"])
SupportDlg = ptAttribGUIDialog(14, "Support dialog")


Expand Down Expand Up @@ -372,6 +372,8 @@
kVideoResSliderTag = 461
kVideoResTextTag = 473
kVideoVerticalSyncCheckTag = 453
kVideoDynamicReflectionsCheckTag = 900
kVideoDynamicReflectionsTextTag = 901

kGSAudioMuteCheckbox = 456
kGSMouseTurnSensSlider = 460
Expand Down Expand Up @@ -585,9 +587,7 @@ def OnGUINotify(self,id,control,event):
###############################################
if id == OptionsMenuDlg.id:
if event == kShowHide:
if control.isEnabled():
textField = ptGUIControlTextBox(OptionsMenuDlg.dialog.getControlFromTag(kOptionsOkText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Resume"))
pass

elif event == kAction or event == kValueChanged:
# test to see which control had the event
Expand Down Expand Up @@ -667,12 +667,6 @@ def OnGUINotify(self,id,control,event):
self._releaseNotesCtrl.lock()
elif event == kShowHide:
if control.isEnabled():
# buttons localized
textField = ptGUIControlTextBox(ReleaseNotesDlg.dialog.getControlFromTag(kRNOkText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Resume"))
textField = ptGUIControlTextBox(ReleaseNotesDlg.dialog.getControlFromTag(kRNGoBackText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.GoBack"))

# BOOM if you do this on dialog load. Probably due to how early it happens
# in the init process. Do it now.
if not self._releaseNotesCtrl.getBufferSize():
Expand Down Expand Up @@ -701,42 +695,6 @@ def OnGUINotify(self,id,control,event):
elif id == KeyMapDlg.id:
if event == kDialogLoaded:
pass
elif event == kShowHide:
# reset the edit text lines
if control.isEnabled():
# localize the strings
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kKMTextLine1))
textField.setString(PtGetLocalizedString("OptionsMenu.KeyCommands.MoveForward"))
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kKMTextLine2))
textField.setString(PtGetLocalizedString("OptionsMenu.KeyCommands.MoveBackward"))
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kKMTextLine3))
textField.setString(PtGetLocalizedString("OptionsMenu.KeyCommands.RotateLeft"))
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kKMTextLine4))
textField.setString(PtGetLocalizedString("OptionsMenu.KeyCommands.RotateRight"))
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kKMTextLine5))
textField.setString(PtGetLocalizedString("OptionsMenu.KeyCommands.Jump"))
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kKMTextLine6))
textField.setString(PtGetLocalizedString("OptionsMenu.KeyCommands.StrafeLeft"))
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kKMTextLine7))
textField.setString(PtGetLocalizedString("OptionsMenu.KeyCommands.StrafeRight"))
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kKMTextLine8))
textField.setString(PtGetLocalizedString("OptionsMenu.KeyCommands.ExitMode"))
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kKMTextLine9))
textField.setString(PtGetLocalizedString("OptionsMenu.KeyCommands.FirstPerson"))

# buttons localized
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kOptionsOkText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Resume"))
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kOptionsDefaultsText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Defaults"))
textField = ptGUIControlTextBox(KeyMapDlg.dialog.getControlFromTag(kOptionsGoBackText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.GoBack"))
self.IShowMappedKeys(control,gKM1ControlCodesRow1,gKM1ControlCodesRow2)
# read the ini file in
# xIniInput.ReadIni()
else:
# xIniInput.WriteIni()
pass
elif event == kAction or event == kValueChanged:
kmID = control.getTagID()
if kmID == kKMOkBtn:
Expand Down Expand Up @@ -843,31 +801,6 @@ def OnGUINotify(self,id,control,event):
elif event == kShowHide:
if control.isEnabled():
self.IRefreshAdvSettings()

# localize the strings
textField = ptGUIControlTextBox(AdvGameSettingDlg.dialog.getControlFromTag(kAGSAdvanceHeader))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.Advanced"))
textField = ptGUIControlTextBox(AdvGameSettingDlg.dialog.getControlFromTag(kAGSQuickerCameraText))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.SmootherCamera"))
textField = ptGUIControlTextBox(AdvGameSettingDlg.dialog.getControlFromTag(kAGSMouseInvert))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.InvertMouse"))
textField = ptGUIControlTextBox(AdvGameSettingDlg.dialog.getControlFromTag(kAGSWalkAndPan))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.WalkAndPan"))
textField = ptGUIControlTextBox(AdvGameSettingDlg.dialog.getControlFromTag(kAGSStayInFirstPerson))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.StayInFP"))
textField = ptGUIControlTextBox(AdvGameSettingDlg.dialog.getControlFromTag(kAGSClickToTurn))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.ClickToTurn"))
textField = ptGUIControlTextBox(AdvGameSettingDlg.dialog.getControlFromTag(kAGSMouseTurn))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.MouseTurn"))

# buttons localized
textField = ptGUIControlTextBox(AdvGameSettingDlg.dialog.getControlFromTag(kOptionsGoBackText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.GoBack"))
textField = ptGUIControlTextBox(AdvGameSettingDlg.dialog.getControlFromTag(kOptionsOkText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Resume"))
textField = ptGUIControlTextBox(AdvGameSettingDlg.dialog.getControlFromTag(kOptionsDefaultsText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Defaults"))

elif event == kAction or event == kValueChanged:
gsID = control.getTagID()
PtDebugPrint("gsID = " + str(gsID))
Expand Down Expand Up @@ -964,14 +897,7 @@ def OnGUINotify(self,id,control,event):
##
###############################################
elif id == CalibrateDlg.id:
if event == kDialogLoaded:
textField = ptGUIControlTextBox(CalibrateDlg.dialog.getControlFromTag(kCalMessageText))
textField.setString(PtGetLocalizedString("OptionsMenu.Messages.Calibration"))
elif event == kShowHide:
if control.isEnabled():
textField = ptGUIControlTextBox(CalibrateDlg.dialog.getControlFromTag(kCalMessageText))
textField.setString(PtGetLocalizedString("OptionsMenu.Messages.Calibration"))
elif event == kAction or event == kValueChanged:
if event == kAction or event == kValueChanged:
cbID = control.getTagID()
if cbID == kClickOnMeBtn:
CalibrateDlg.dialog.hide()
Expand Down Expand Up @@ -1072,14 +998,6 @@ def OnGUINotify(self,id,control,event):
if control.isEnabled():
self.IRefreshHelpSettings()

# buttons localized
textField = ptGUIControlTextBox(NavigationDlg.dialog.getControlFromTag(kOptionsGoBackText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.GoBack"))
textField = ptGUIControlTextBox(NavigationDlg.dialog.getControlFromTag(kOptionsOkText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Resume"))
textField = ptGUIControlTextBox(NavigationDlg.dialog.getControlFromTag(kGSAdvancedBtnText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Advanced"))

elif event == kAction or event == kValueChanged:
NavigationID = control.getTagID()
PtDebugPrint("NavigationID = ", NavigationID)
Expand Down Expand Up @@ -1124,16 +1042,6 @@ def OnGUINotify(self,id,control,event):
if event == kShowHide:
if control.isEnabled():
self.InitVideoControlsGUI()

# buttons localized
# Temporary HACK - These controls lack TagIDs in the 902 PRPs, so we're going to call them up by index instead.
textField = ptGUIControlTextBox(GraphicsSettingsDlg.dialog.getControlFromIndex(3)) # (kOptionsGoBackText) GSGoBackBtnText_5
textField.setString(PtGetLocalizedString("OptionsMenu.Main.GoBack"))
textField = ptGUIControlTextBox(GraphicsSettingsDlg.dialog.getControlFromIndex(4)) # (kOptionsOkText) GSOkBtnText_6
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Resume"))
textField = ptGUIControlTextBox(GraphicsSettingsDlg.dialog.getControlFromIndex(6)) # (kOptionsDefaultsText) GSDefaultsBtnText_2
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Defaults"))

self.restartWarn = 0

elif (event == kAction or event == kValueChanged):
Expand Down Expand Up @@ -1253,30 +1161,6 @@ def OnGUINotify(self,id,control,event):
elif event == kShowHide:
# reset the edit text lines
if control.isEnabled():
# localize the strings
textField = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kGSVolumeHeader))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.AudioSettings"))
textField = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kGSVolSoundFXText))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.SoundFX"))
textField = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kGSVolMusicText))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.Music"))
textField = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kGSMyVoiceHeader))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.MyVoice"))
textField = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kGSVolAmbientText))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.Ambient"))
textField = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kGSVoiceHeader))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.OtherVoice"))
textField = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kGSVolMuteText))
textField.setString(PtGetLocalizedString("OptionsMenu.GameSettings.Mute"))

# buttons localized
textField = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kOptionsGoBackText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.GoBack"))
textField = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kOptionsOkText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Resume"))
textField = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kOptionsDefaultsText))
textField.setString(PtGetLocalizedString("OptionsMenu.Main.Defaults"))

self.restartAudio = 0

else:
Expand Down Expand Up @@ -1568,6 +1452,19 @@ def InitVideoControlsGUI(self):
else:
videoField.setChecked(0)

dynReflCB = GraphicsSettingsDlg.dialog.getControlModFromTag(kVideoDynamicReflectionsCheckTag)
dynReflTB = GraphicsSettingsDlg.dialog.getControlModFromTag(kVideoDynamicReflectionsTextTag)
if PtSupportsPlanarReflections():
respDisableItems.run(self.key, state="enableDynRefl")
dynReflCB.setChecked(bool(opts[xIniDisplay.kGraphicsDynamicReflections]))
dynReflCB.enable()
dynReflTB.setForeColor(ptColor().white())
else:
respDisableItems.run(self.key, state="disableDynRefl")
dynReflCB.setChecked(False)
dynReflCB.disable()
dynReflTB.setForeColor(ptColor(0.839, 0.785, 0.695, 1))

# video res stuff
vidRes = str(opts[xIniDisplay.kGraphicsWidth]) + "x" + str(opts[xIniDisplay.kGraphicsHeight])
videoResField = ptGUIControlTextBox(GraphicsSettingsDlg.dialog.getControlFromTag(kVideoResTextTag))
Expand Down Expand Up @@ -1685,7 +1582,9 @@ def WriteVideoControls(self, setMode = 0):
gammaField = ptGUIControlKnob(GraphicsSettingsDlg.dialog.getControlFromTag(kGSDisplayGammaSlider))
gamma = gammaField.getValue()

xIniDisplay.SetGraphicsOptions(width, height, colordepth, windowed, tex_quality, antialias, aniso, quality, shadowsstr, vsyncstr, shadow_quality)
dynRefl = int(GraphicsSettingsDlg.dialog.getControlModFromTag(kVideoDynamicReflectionsCheckTag).isChecked())

xIniDisplay.SetGraphicsOptions(width, height, colordepth, windowed, tex_quality, antialias, aniso, quality, shadowsstr, vsyncstr, shadow_quality, dynRefl)
xIniDisplay.WriteIni()
self.setNewChronicleVar("gamma", gamma)

Expand All @@ -1694,6 +1593,7 @@ def WriteVideoControls(self, setMode = 0):
PtDebugPrint("SETTING GAMMA")
PtSetGamma2(gamma)
PtSetShadowVisDistance(shadow_quality)
PtEnablePlanarReflections(dynRefl)

if shadows:
PtEnableShadows()
Expand Down
5 changes: 5 additions & 0 deletions Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,11 @@ void cyMisc::EnablePlanarReflections(bool enable)
plDynamicCamMap::SetEnabled(enable);
}

bool cyMisc::ArePlanarReflectionsSupported()
{
return plDynamicCamMap::GetCapable();
}

void cyMisc::GetSupportedDisplayModes(std::vector<plDisplayMode> *res)
{
fPipeline->GetSupportedDisplayModes(res);
Expand Down
1 change: 1 addition & 0 deletions Sources/Plasma/FeatureLib/pfPython/cyMisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,7 @@ class cyMisc
static ST::string GetLocalizedString(const ST::string& name, const std::vector<ST::string> & arguments);

static void EnablePlanarReflections(bool enable = true);
static bool ArePlanarReflectionsSupported();
static void SetGraphicsOptions(int Width, int Height, int ColorDepth, bool Windowed, int NumAASamples, int MaxAnisotropicSamples, bool VSync);
static void GetSupportedDisplayModes(std::vector<plDisplayMode> *res);
static int GetDesktopWidth();
Expand Down
6 changes: 6 additions & 0 deletions Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,11 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtEnablePlanarReflections, args, "Params: on\nEn
PYTHON_RETURN_NONE;
}

PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtSupportsPlanarReflections, "Returns if planar reflections are supported")
{
return PyBool_FromLong(cyMisc::ArePlanarReflectionsSupported() ? 1 : 0);
}

PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetSupportedDisplayModes, "Returns a list of supported resolutions")
{
std::vector<plDisplayMode> res;
Expand Down Expand Up @@ -818,6 +823,7 @@ void cyMisc::AddPlasmaMethods4(PyObject* m)
PYTHON_GLOBAL_METHOD_NOARGS(PtCheckVisLOSFromCursor)

PYTHON_GLOBAL_METHOD(PtEnablePlanarReflections)
PYTHON_GLOBAL_METHOD_NOARGS(PtSupportsPlanarReflections)
PYTHON_GLOBAL_METHOD_NOARGS(PtGetSupportedDisplayModes)
PYTHON_GLOBAL_METHOD_NOARGS(PtGetDesktopWidth)
PYTHON_GLOBAL_METHOD_NOARGS(PtGetDesktopHeight)
Expand Down
Loading