misc cleanup

This commit is contained in:
Open Toontown 2023-04-23 23:18:37 -04:00
parent 22f87eb182
commit 327fb57e61
4 changed files with 59 additions and 31 deletions

View file

@ -1,11 +1,18 @@
from direct.interval.IntervalGlobal import *
from direct.task.Task import Task
from panda3d.core import Point3, Vec3
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.interval.IntervalGlobal import LerpHprInterval
from direct.showbase.PythonUtil import fitSrcAngle2Dest
from direct.task.TaskManagerGlobal import taskMgr
from otp.otpbase import OTPGlobals
from toontown.toonbase.ToonBaseGlobal import *
from . import ArrowKeys
from toontown.minigame.ArrowKeys import ArrowKeys
from toontown.toonbase.ToonBaseGlobal import base
class OrthoDrive:
notify = DirectNotifyGlobal.directNotify.newCategory('OrthoDrive')
notify = directNotify.newCategory('OrthoDrive')
TASK_NAME = 'OrthoDriveTask'
SET_ATREST_HEADING_TASK = 'setAtRestHeadingTask'
@ -17,7 +24,7 @@ class OrthoDrive:
self.priority = priority
self.setHeading = setHeading
self.upHeading = upHeading
self.arrowKeys = ArrowKeys.ArrowKeys()
self.arrowKeys = ArrowKeys()
self.lt = base.localAvatar
self.instantTurn = instantTurn
@ -85,7 +92,7 @@ class OrthoDrive:
if self.setHeading:
self.__handleHeading(xVel, yVel)
toonPos = self.lt.getPos()
dt = globalClock.getDt()
dt = base.clock.getDt()
posOffset = vel * dt
posOffset += toonPos - self.lastPos
toonPos = self.lastPos
@ -100,7 +107,7 @@ class OrthoDrive:
toonPos = toonPos + posOffset
self.lt.setPos(toonPos)
self.lastPos = toonPos
return Task.cont
return task.cont
def __handleHeading(self, xVel, yVel):
def getHeading(xVel, yVel):
@ -126,7 +133,7 @@ class OrthoDrive:
if ((self.lastXVel and self.lastYVel) and not (xVel and yVel)):
def setAtRestHeading(task, self = self, angle = curHeading):
self.atRestHeading = angle
return Task.done
return task.done
taskMgr.doMethodLater(0.05, setAtRestHeading, OrthoDrive.SET_ATREST_HEADING_TASK)
else:

View file

@ -1,11 +1,19 @@
from toontown.toonbase.ToonBaseGlobal import *
from panda3d.core import Point3, Vec3
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.interval.IntervalGlobal import LerpHprInterval
from direct.showbase.MessengerGlobal import messenger
from direct.showbase.PythonUtil import fitSrcAngle2Dest
from direct.task.TaskManagerGlobal import taskMgr
from otp.otpbase import OTPGlobals
from direct.interval.IntervalGlobal import *
from . import ArrowKeys
from direct.task.Task import Task
from toontown.minigame.ArrowKeys import ArrowKeys
from toontown.toonbase.ToonBaseGlobal import base
class TwoDDrive:
notify = DirectNotifyGlobal.directNotify.newCategory('TwoDDrive')
notify = directNotify.newCategory('TwoDDrive')
TASK_NAME = 'TwoDDriveTask'
SET_ATREST_HEADING_TASK = 'setAtRestHeadingTask'
@ -17,7 +25,7 @@ class TwoDDrive:
self.priority = priority
self.setHeading = setHeading
self.upHeading = upHeading
self.arrowKeys = ArrowKeys.ArrowKeys()
self.arrowKeys = ArrowKeys()
self.wasUpReleased = True
self.lt = base.localAvatar
base.localAvatar.useTwoDControls()
@ -78,11 +86,11 @@ class TwoDDrive:
elif self.arrowKeys.upPressed() and self.wasUpReleased:
self.wasUpReleased = False
if not self.game.isHeadInFloor:
if localAvatar.controlManager.currentControls == localAvatar.controlManager.get('twoD'):
if base.localAvatar.controlManager.currentControls == base.localAvatar.controlManager.get('twoD'):
base.localAvatar.controlManager.currentControls.jumpPressed()
elif self.arrowKeys.upPressed():
if not self.game.isHeadInFloor:
if localAvatar.controlManager.currentControls == localAvatar.controlManager.get('twoD'):
if base.localAvatar.controlManager.currentControls == base.localAvatar.controlManager.get('twoD'):
base.localAvatar.controlManager.currentControls.jumpPressed()
if self.arrowKeys.leftPressed():
xVel -= 1
@ -110,7 +118,7 @@ class TwoDDrive:
if self.setHeading:
self.__handleHeading(xVel, yVel)
toonPos = self.lt.getPos()
dt = globalClock.getDt()
dt = base.clock.getDt()
posOffset = vel * dt
if self.customCollisionCallback:
toonPos = self.customCollisionCallback(toonPos, toonPos + posOffset)
@ -118,7 +126,7 @@ class TwoDDrive:
toonPos += posOffset
self.lt.setPos(toonPos)
self.lastPos = toonPos
return Task.cont
return task.cont
def __handleHeading(self, xVel, yVel):
def getHeading(xVel, yVel):
@ -144,7 +152,7 @@ class TwoDDrive:
if ((self.lastXVel and self.lastYVel) and not (xVel and yVel)):
def setAtRestHeading(task, self = self, angle = curHeading):
self.atRestHeading = angle
return Task.done
return task.done
taskMgr.doMethodLater(0.05, setAtRestHeading, TwoDDrive.SET_ATREST_HEADING_TASK)
else:

View file

@ -1 +1,5 @@
from .ToonBase import *
__all__ = ['base']
from .ToonBase import ToonBase
base = ToonBase()

View file

@ -6,7 +6,20 @@ class game:
builtins.game = game()
from panda3d.core import *
from panda3d.core import (
ConfigVariableBool,
ConfigVariableDouble,
ConfigVariableString,
Filename,
HTTPClient,
Loader,
loadPrcFile,
TextNode,
Thread,
VBase3,
Vec4
)
import time
import sys
try:
@ -38,8 +51,7 @@ print('ToontownStart: setting default font')
from . import ToontownGlobals
DirectGuiGlobals.setDefaultFontFunc(ToontownGlobals.getInterfaceFont)
launcher.setPandaErrorCode(7)
from . import ToonBase
ToonBase.ToonBase()
from .ToonBaseGlobal import base
if base.win == None:
print('Unable to open window; aborting.')
sys.exit()
@ -70,21 +82,19 @@ if base.musicManagerIsValid:
DirectGuiGlobals.setDefaultClickSound(base.loader.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
else:
music = None
from direct.gui.DirectGui import *
from direct.gui.DirectGui import OnscreenText
serverVersion = ConfigVariableString('server-version', 'no_version_set').value
print('ToontownStart: serverVersion: ', serverVersion)
version = OnscreenText(serverVersion, pos=(-1.3, -0.975), scale=0.06, fg=Vec4(0, 0, 1, 0.6), align=TextNode.ALeft)
loader.beginBulkLoad('init', TTLocalizer.LoaderLabel, 138, 0, TTLocalizer.TIP_NONE)
from .ToonBaseGlobal import *
from direct.showbase.MessengerGlobal import *
from toontown.distributed import ToontownClientRepository
cr = ToontownClientRepository.ToontownClientRepository(serverVersion, launcher)
from toontown.distributed.ToontownClientRepository import ToontownClientRepository
cr = ToontownClientRepository(serverVersion, launcher)
cr.music = music
del music
base.initNametagGlobals()
base.cr = cr
loader.endBulkLoad('init')
from otp.distributed.OtpDoGlobals import *
from otp.distributed.OtpDoGlobals import OTP_DO_ID_FRIEND_MANAGER
cr.generateGlobalObject(OTP_DO_ID_FRIEND_MANAGER, 'FriendManager')
if not launcher.isDummy():
base.startShow(cr, launcher.getGameServer())
@ -97,7 +107,6 @@ del backgroundNode
del tempLoader
version.cleanup()
del version
base.loader = base.loader
builtins.loader = base.loader
autoRun = ConfigVariableBool('toontown-auto-run', 1)
if autoRun and launcher.isDummy() and (not Thread.isTrueThreads() or __name__ == '__main__'):