Skip to content

Commit

Permalink
Fix stage prop placement ffs
Browse files Browse the repository at this point in the history
  • Loading branch information
FluffyOMC committed May 27, 2024
1 parent 5f48eb8 commit 4114aa5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
4 changes: 2 additions & 2 deletions psychtobase/src/tools/StageLuaParse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def parseStage(lua_script_path):

calls = {}

allowedMethods = ['makeLuaSprite', 'makeAnimatedLuaSprite', 'addAnimationByPrefix', 'addLuaSprite']
allowedMethods = ['makeLuaSprite', 'setScrollFactor', 'scaleObject', 'makeAnimatedLuaSprite', 'addAnimationByPrefix', 'addLuaSprite']
allowedFuncs = ['onCreate', 'onCreatePost']

# Note: addLuaSprite only checks for if a character is after the characters!
Expand Down Expand Up @@ -66,7 +66,7 @@ def parseStage(lua_script_path):
calls[curFunc][node.func.id].append(arguments)

except Exception as e:
logging.error(f'Failed to asign arguments of this call: {e}')
logging.error(f'Failed to assign arguments of this call: {e}')

#print(f'{calls}')

Expand Down
38 changes: 26 additions & 12 deletions psychtobase/src/tools/StageTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,25 @@ def getProps(parentFunc, parentFuncName, luaFilename):
sprite = pictureProp[2]

# Why do I have to add a try except for everything
posx = 0
posy = 0
pos = [0.0, 0.0]
scale = [1.0, 1.0]
scroll = [1.0, 1.0]

try:
posx = pictureProp[3]
posy = pictureProp[4]
pos = [float(pictureProp[3]), float(pictureProp[4])]
except:
logging.error(f'[{luaFilename}] Failed accessing x and y of prop! Did you check if it is defined?')

for func in parentFunc.get('scaleObject', []):
if func[1] == tag:
scale = [float(func[2]), float(func[3])]
break

for func in parentFunc.get('setScrollFactor', []):
if func[1] == tag:
scroll = [float(func[2]), float(func[3])]
break

call = pictureProp[0]

z_index = 0
Expand All @@ -54,11 +64,13 @@ def getProps(parentFunc, parentFuncName, luaFilename):
_props.append({
't': tag, # Tag
's': sprite, # Sprite
'x': posx, # X
'y': posy, # Y
'x': pos[0], # X
'y': pos[1], # Y
'z': z_index, # Z index
'a': animated, # Animated
'as': [] # Animations
'as': [], # Animations
'scale': scale, # Scale
'scroll': scroll # Scroll
})

for animationAdd in parentFunc.get('addAnimationByPrefix', []):
Expand Down Expand Up @@ -113,6 +125,8 @@ def toFNFProps(props):
posY = prop['y']
posZ = prop['z']
animations = prop['as']
scale = prop['scale']
scroll = prop['scroll']

_prop_template = None

Expand All @@ -126,19 +140,19 @@ def toFNFProps(props):

_prop_template['name'] = name
_prop_template['assetPath'] = assetPath
_posX = 0
_posY = 0

try:
#Should probably have these as a prompt in the future
_posX = float(posX) - 1000
#Should probably have this as a prompt in the future
_posY = float(posY) - 720
except Exception as e:
logging.error(f'Error converting x and y values: {e}')
logging.error(f'Error converting y value: {e}')

_prop_template['position'][0] = _posX
_prop_template['position'][0] = posX
_prop_template['position'][1] = _posY
_prop_template['zIndex'] = posZ
_prop_template['scale'] = scale
_prop_template['scroll'] = scroll

if animated:
for animation in animations:
Expand Down

0 comments on commit 4114aa5

Please sign in to comment.