Skip to content

Commit

Permalink
Merge pull request m2ci-msp#38 from ahewer/master
Browse files Browse the repository at this point in the history
Multiple changes and fixes
  • Loading branch information
Alexander Hewer authored Sep 10, 2016
2 parents 451fc10 + d336a3d commit 17f0b93
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 10 deletions.
17 changes: 15 additions & 2 deletions ematoblender/scripts/ema_blender/ema_bge/bge_play_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import time
import random
import math
import json
import os
import bpy

from .. import blender_shared_objects as bsh
from ...ema_shared import properties as pps

Expand All @@ -30,9 +34,18 @@ def sound_setup(*filepath):
sound_actuator = bge.logic.getCurrentController().owner.actuators['SoundAct']
#print(sound_actuator, sound_actuator.__dir__())

# get override information
userPref = bpy.utils.script_path_pref()
overridesFile = os.path.join(userPref, "ema_shared", "overrides.json")
fileStream = open(overridesFile, "r")
overrides = json.load(fileStream)
fileStream.close()

audioOverride = overrides["audio"]

# prepare the sound factory
if pps.sound_override is not None and os.path.isfile(pps.sound_override):
soundpath = pps.sound_override
if audioOverride["active"] == True:
soundpath = audioOverride["path"]
print('USING MANUAL SOUND OVERRIDE:', soundpath)
else:
soundpath = bsh.soundpath
Expand Down
18 changes: 18 additions & 0 deletions ematoblender/scripts/ema_io/ema_gameserver/OverrideSettings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
__author__ = "Alexander Hewer"
__email__ = "hewer@coli.uni-saarland.de"

import json

class OverrideSettings:

overrides = {
"audio" : { "active" : False}
}

def save():

jsonData = {}

output = open("ematoblender/scripts/ema_shared/overrides.json", "w")
json.dump(__class__.overrides, output)
output.close()
8 changes: 8 additions & 0 deletions ematoblender/scripts/ema_io/ema_gameserver/SettingsReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .GameServerSettings import GameServerSettings
from .ExternalFittingServerSettings import ExternalFittingServerSettings
from .CoilSettings import CoilSettings
from .OverrideSettings import OverrideSettings

class SettingsReader:

Expand All @@ -17,6 +18,7 @@ def read_from(fileName):
__class__.set_game_server_settings(settingsDictionary["gameServerSettings"])
__class__.set_external_fitting_server_settings(settingsDictionary["externalFittingServerSettings"])
__class__.set_coil_settings(settingsDictionary["coilSettings"])
__class__.set_override_settings(settingsDictionary["overrideSettings"])

def set_game_server_settings(settings):

Expand Down Expand Up @@ -50,3 +52,9 @@ def set_coil_settings(settings):

CoilSettings.coils = settings
CoilSettings.save()

def set_override_settings(settings):

OverrideSettings.overrides = settings
OverrideSettings.save()

6 changes: 6 additions & 0 deletions ematoblender/scripts/ema_io/ema_gameserver/SettingsWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .GameServerSettings import GameServerSettings
from .ExternalFittingServerSettings import ExternalFittingServerSettings
from .CoilSettings import CoilSettings
from .OverrideSettings import OverrideSettings

class SettingsWriter:

Expand All @@ -17,6 +18,7 @@ def write_to(fileName):
settingsDictionary["gameServerSettings"] = __class__.get_game_server_settings()
settingsDictionary["externalFittingServerSettings"] = __class__.get_external_fitting_server_settings()
settingsDictionary["coilSettings"] = __class__.get_coil_settings()
settingsDictionary["overrideSettings"] = __class__.get_override_settings()

fileStream.write(json.dumps(settingsDictionary, indent=4, sort_keys=True))

Expand Down Expand Up @@ -62,3 +64,7 @@ def get_external_fitting_server_settings():
def get_coil_settings():

return CoilSettings.coils

def get_override_settings():

return OverrideSettings.overrides
12 changes: 6 additions & 6 deletions ematoblender/scripts/ema_io/ema_gameserver/gameserver_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .GameServerSettings import GameServerSettings
from .SettingsReader import SettingsReader
from .SettingsWriter import SettingsWriter
from .OverrideSettings import OverrideSettings
from . import rtclient as rtc
from ...ema_shared import properties as pps

Expand Down Expand Up @@ -62,6 +63,8 @@ def on_closing(r, a):
class Application(tk.Frame):
""" GUI class for the gameserver application. """
def __init__(self, master=None, servobj=None):

OverrideSettings.save()
tk.Frame.__init__(self, master)
self.root = master

Expand Down Expand Up @@ -281,19 +284,18 @@ def createRightFrame(self):

def record_biteplane():
self.biteplane_live_status.set('Button pressed')
self.biteplane_live_status_lbl.update()

try:
secs = int(self.biteplane_secentry.get())
except ValueError:
self.biteplane_secentry.text = ''
self.biteplane_live_status.set('INVALID SECONDS')
self.biteplane_live_status_lbl.update()

else:
self.biteplane_live_status.set('RECORDING')
self.biteplane_live_status_lbl.update()

self.servobj.headcorrection.load_live(self.servobj, seconds=secs)

GameServerSettings.bitePlane["origin"] = tuple(self.servobj.headcorrection.biteplane.origin)
GameServerSettings.bitePlane["xAxis"] = tuple(self.servobj.headcorrection.biteplane.x_axis)
GameServerSettings.bitePlane["yAxis"] = tuple(self.servobj.headcorrection.biteplane.y_axis)
Expand All @@ -320,8 +322,6 @@ def record_biteplane():

def record_refpoint():
self.ref_live_status.set('RECORDING')
self.ref_live_status_lbl.update()

secs = int(self.ref_secentry.get())
self.servobj.referencePointBuilder.load_live(self.servobj, seconds=secs)
GameServerSettings.bitePlane["shiftedOrigin"] = tuple(self.servobj.headcorrection.biteplane.shiftedOrigin)
Expand Down
4 changes: 2 additions & 2 deletions ematoblender/scripts/ema_shared/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
LL_empty_name = 'LL_Empty'

# show debugging lines
show_debugging_lines = True
show_debugging_lines = False


# choose to send things to wave, like requesting frequency of streaming etc
Expand All @@ -122,7 +122,7 @@
tongue_intervals = 9

# cameras to give viewports to
display_cameras = ['FCamera', 'MSCamera'] # missing CircularCamera # ]#] # TODO: DrawLine does not respond to this, so cannot use debuggin with 2 cams.
display_cameras = ['MSCamera', 'CircularCamera'] # 'FCamera', 'MSCamera'] # missing CircularCamera # ]#] # TODO: DrawLine does not respond to this, so cannot use debuggin with 2 cams.

development_mode = True

Expand Down
1 change: 1 addition & 0 deletions gradlescripts/fetchResources/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ task fetchExamples() {
src( [
"https://github.com/m2ci-msp/ematoblender-example-data/releases/download/v0.1/VP08_bitePlane.json",
"https://github.com/m2ci-msp/ematoblender-example-data/releases/download/v0.1/VP08_nordwind.json",
"https://github.com/m2ci-msp/ematoblender-example-data/releases/download/v0.1/VP08_nordwind.wav",
"https://github.com/m2ci-msp/ematoblender-example-data/releases/download/v0.1/VP08_referencePoint.json"
])

Expand Down

0 comments on commit 17f0b93

Please sign in to comment.