Skip to content

Commit

Permalink
GUIScript: merged two similar bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
lynxlynxlynx committed Mar 30, 2024
1 parent 385036a commit 3e7d2c7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 36 deletions.
5 changes: 3 additions & 2 deletions gemrb/GUIScripts/GUIOPT.py
Expand Up @@ -35,6 +35,7 @@
import GUISAVE
import GUIOPTControls
from GUIDefines import *
from ie_sounds import GEM_SND_VOL_MUSIC, GEM_SND_VOL_AMBIENTS

###################################################

Expand Down Expand Up @@ -223,11 +224,11 @@ def OpenAudioOptionsWindow ():

def DisplayHelpAmbientVolume ():
GemRB.GetView ("OPTHELP").SetText (18008)
GemRB.UpdateAmbientsVolume ()
GemRB.UpdateVolume (GEM_SND_VOL_AMBIENTS)

def DisplayHelpMusicVolume ():
GemRB.GetView ("OPTHELP").SetText (18011)
GemRB.UpdateMusicVolume ()
GemRB.UpdateVolume (GEM_SND_VOL_MUSIC)

###################################################

Expand Down
4 changes: 2 additions & 2 deletions gemrb/GUIScripts/TextScreen.py
Expand Up @@ -19,7 +19,7 @@

import GemRB
from ie_restype import RES_2DA
from ie_sounds import CHAN_GUI, SND_SPEECH
from ie_sounds import CHAN_GUI, SND_SPEECH, GEM_SND_VOL_AMBIENTS
from GUIDefines import *
import GameCheck

Expand Down Expand Up @@ -174,7 +174,7 @@ def ToggleAmbients (state):
AmbientVolume = GemRB.GetVar ("Volume Ambients")
GemRB.SetVar ("Volume Ambients", 0)

GemRB.UpdateAmbientsVolume ()
GemRB.UpdateVolume (GEM_SND_VOL_AMBIENTS)

def EndTextScreen ():
global TextScreen, TableName
Expand Down
4 changes: 4 additions & 0 deletions gemrb/GUIScripts/ie_sounds.py
Expand Up @@ -54,3 +54,7 @@
SND_SPEECH = 4
SND_QUEUE = 8
SND_EFX = 16

# from Audio.h
GEM_SND_VOL_MUSIC = 1
GEM_SND_VOL_AMBIENTS = 2
3 changes: 1 addition & 2 deletions gemrb/GUIScripts/pst/GUIOPT.py
Expand Up @@ -173,8 +173,7 @@ def UpdateVolume (volume_ref):
helpTA = GemRB.GetView ("OPTHELP")
if helpTA:
helpTA.SetText (volume_ref)
GemRB.UpdateAmbientsVolume ()
GemRB.UpdateMusicVolume ()
GemRB.UpdateVolume ()

###################################################

Expand Down
45 changes: 15 additions & 30 deletions gemrb/plugins/GUIScript/GUIScript.cpp
Expand Up @@ -7877,40 +7877,26 @@ static PyObject* GemRB_EvaluateString(PyObject * /*self*/, PyObject* args)
Py_RETURN_NONE;
}

PyDoc_STRVAR( GemRB_UpdateMusicVolume__doc,
"===== UpdateMusicVolume =====\n\
PyDoc_STRVAR(GemRB_UpdateVolume__doc,
"===== UpdateVolume =====\n\
\n\
**Prototype:** GemRB.UpdateMusicVolume ()\n\
**Prototype:** GemRB.UpdateVolume ([type])\n\
\n\
**Description:** Updates music volume on-the-fly.\n\
**Description:** Updates volume on-the-fly.\n\
\n\
**Return value:** N/A\n\
\n\
**See also:** [UpdateAmbientsVolume](UpdateAmbientsVolume.md)"
);

static PyObject* GemRB_UpdateMusicVolume(PyObject * /*self*/, PyObject* /*args*/)
{
core->GetAudioDrv()->UpdateVolume( GEM_SND_VOL_MUSIC );

Py_RETURN_NONE;
}

PyDoc_STRVAR( GemRB_UpdateAmbientsVolume__doc,
"===== UpdateAmbientsVolume =====\n\
\n\
**Prototype:** GemRB.UpdateAmbientsVolume ()\n\
\n\
**Description:** Updates ambients volume on-the-fly.\n\
**Parameters**:\n\
* type:\n\
* 1 - music\n\
* 2 - ambients\n\
* 3 - both, default\n\
\n\
**Return value:** N/A\n\
\n\
**See also:** [UpdateMusicVolume](UpdateMusicVolume.md)"
);
**Return value:** N/A");

static PyObject* GemRB_UpdateAmbientsVolume(PyObject * /*self*/, PyObject* /*args*/)
static PyObject* GemRB_UpdateVolume(PyObject* /*self*/, PyObject* args)
{
core->GetAudioDrv()->UpdateVolume( GEM_SND_VOL_AMBIENTS );
int type = 3;
PARSE_ARGS(args, "i", &type);
core->GetAudioDrv()->UpdateVolume(type);

Py_RETURN_NONE;
}
Expand Down Expand Up @@ -13157,8 +13143,7 @@ static PyMethodDef GemRBMethods[] = {
METHOD(SpellCast, METH_VARARGS),
METHOD(StealFailed, METH_NOARGS),
METHOD(UnmemorizeSpell, METH_VARARGS),
METHOD(UpdateAmbientsVolume, METH_NOARGS),
METHOD(UpdateMusicVolume, METH_NOARGS),
METHOD(UpdateVolume, METH_VARARGS),
METHOD(UpdateWorldMap, METH_VARARGS),
METHOD(UseItem, METH_VARARGS),
METHOD(ValidTarget, METH_VARARGS),
Expand Down

0 comments on commit 3e7d2c7

Please sign in to comment.