misc cleanup
This commit is contained in:
parent
22f87eb182
commit
327fb57e61
4 changed files with 59 additions and 31 deletions
|
@ -1,11 +1,18 @@
|
||||||
from direct.interval.IntervalGlobal import *
|
from panda3d.core import Point3, Vec3
|
||||||
from direct.task.Task import Task
|
|
||||||
|
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 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:
|
class OrthoDrive:
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('OrthoDrive')
|
notify = directNotify.newCategory('OrthoDrive')
|
||||||
TASK_NAME = 'OrthoDriveTask'
|
TASK_NAME = 'OrthoDriveTask'
|
||||||
SET_ATREST_HEADING_TASK = 'setAtRestHeadingTask'
|
SET_ATREST_HEADING_TASK = 'setAtRestHeadingTask'
|
||||||
|
|
||||||
|
@ -17,7 +24,7 @@ class OrthoDrive:
|
||||||
self.priority = priority
|
self.priority = priority
|
||||||
self.setHeading = setHeading
|
self.setHeading = setHeading
|
||||||
self.upHeading = upHeading
|
self.upHeading = upHeading
|
||||||
self.arrowKeys = ArrowKeys.ArrowKeys()
|
self.arrowKeys = ArrowKeys()
|
||||||
self.lt = base.localAvatar
|
self.lt = base.localAvatar
|
||||||
self.instantTurn = instantTurn
|
self.instantTurn = instantTurn
|
||||||
|
|
||||||
|
@ -85,7 +92,7 @@ class OrthoDrive:
|
||||||
if self.setHeading:
|
if self.setHeading:
|
||||||
self.__handleHeading(xVel, yVel)
|
self.__handleHeading(xVel, yVel)
|
||||||
toonPos = self.lt.getPos()
|
toonPos = self.lt.getPos()
|
||||||
dt = globalClock.getDt()
|
dt = base.clock.getDt()
|
||||||
posOffset = vel * dt
|
posOffset = vel * dt
|
||||||
posOffset += toonPos - self.lastPos
|
posOffset += toonPos - self.lastPos
|
||||||
toonPos = self.lastPos
|
toonPos = self.lastPos
|
||||||
|
@ -100,7 +107,7 @@ class OrthoDrive:
|
||||||
toonPos = toonPos + posOffset
|
toonPos = toonPos + posOffset
|
||||||
self.lt.setPos(toonPos)
|
self.lt.setPos(toonPos)
|
||||||
self.lastPos = toonPos
|
self.lastPos = toonPos
|
||||||
return Task.cont
|
return task.cont
|
||||||
|
|
||||||
def __handleHeading(self, xVel, yVel):
|
def __handleHeading(self, xVel, yVel):
|
||||||
def getHeading(xVel, yVel):
|
def getHeading(xVel, yVel):
|
||||||
|
@ -126,7 +133,7 @@ class OrthoDrive:
|
||||||
if ((self.lastXVel and self.lastYVel) and not (xVel and yVel)):
|
if ((self.lastXVel and self.lastYVel) and not (xVel and yVel)):
|
||||||
def setAtRestHeading(task, self = self, angle = curHeading):
|
def setAtRestHeading(task, self = self, angle = curHeading):
|
||||||
self.atRestHeading = angle
|
self.atRestHeading = angle
|
||||||
return Task.done
|
return task.done
|
||||||
|
|
||||||
taskMgr.doMethodLater(0.05, setAtRestHeading, OrthoDrive.SET_ATREST_HEADING_TASK)
|
taskMgr.doMethodLater(0.05, setAtRestHeading, OrthoDrive.SET_ATREST_HEADING_TASK)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -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 otp.otpbase import OTPGlobals
|
||||||
from direct.interval.IntervalGlobal import *
|
|
||||||
from . import ArrowKeys
|
from toontown.minigame.ArrowKeys import ArrowKeys
|
||||||
from direct.task.Task import Task
|
from toontown.toonbase.ToonBaseGlobal import base
|
||||||
|
|
||||||
|
|
||||||
class TwoDDrive:
|
class TwoDDrive:
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('TwoDDrive')
|
notify = directNotify.newCategory('TwoDDrive')
|
||||||
TASK_NAME = 'TwoDDriveTask'
|
TASK_NAME = 'TwoDDriveTask'
|
||||||
SET_ATREST_HEADING_TASK = 'setAtRestHeadingTask'
|
SET_ATREST_HEADING_TASK = 'setAtRestHeadingTask'
|
||||||
|
|
||||||
|
@ -17,7 +25,7 @@ class TwoDDrive:
|
||||||
self.priority = priority
|
self.priority = priority
|
||||||
self.setHeading = setHeading
|
self.setHeading = setHeading
|
||||||
self.upHeading = upHeading
|
self.upHeading = upHeading
|
||||||
self.arrowKeys = ArrowKeys.ArrowKeys()
|
self.arrowKeys = ArrowKeys()
|
||||||
self.wasUpReleased = True
|
self.wasUpReleased = True
|
||||||
self.lt = base.localAvatar
|
self.lt = base.localAvatar
|
||||||
base.localAvatar.useTwoDControls()
|
base.localAvatar.useTwoDControls()
|
||||||
|
@ -78,11 +86,11 @@ class TwoDDrive:
|
||||||
elif self.arrowKeys.upPressed() and self.wasUpReleased:
|
elif self.arrowKeys.upPressed() and self.wasUpReleased:
|
||||||
self.wasUpReleased = False
|
self.wasUpReleased = False
|
||||||
if not self.game.isHeadInFloor:
|
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()
|
base.localAvatar.controlManager.currentControls.jumpPressed()
|
||||||
elif self.arrowKeys.upPressed():
|
elif self.arrowKeys.upPressed():
|
||||||
if not self.game.isHeadInFloor:
|
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()
|
base.localAvatar.controlManager.currentControls.jumpPressed()
|
||||||
if self.arrowKeys.leftPressed():
|
if self.arrowKeys.leftPressed():
|
||||||
xVel -= 1
|
xVel -= 1
|
||||||
|
@ -110,7 +118,7 @@ class TwoDDrive:
|
||||||
if self.setHeading:
|
if self.setHeading:
|
||||||
self.__handleHeading(xVel, yVel)
|
self.__handleHeading(xVel, yVel)
|
||||||
toonPos = self.lt.getPos()
|
toonPos = self.lt.getPos()
|
||||||
dt = globalClock.getDt()
|
dt = base.clock.getDt()
|
||||||
posOffset = vel * dt
|
posOffset = vel * dt
|
||||||
if self.customCollisionCallback:
|
if self.customCollisionCallback:
|
||||||
toonPos = self.customCollisionCallback(toonPos, toonPos + posOffset)
|
toonPos = self.customCollisionCallback(toonPos, toonPos + posOffset)
|
||||||
|
@ -118,7 +126,7 @@ class TwoDDrive:
|
||||||
toonPos += posOffset
|
toonPos += posOffset
|
||||||
self.lt.setPos(toonPos)
|
self.lt.setPos(toonPos)
|
||||||
self.lastPos = toonPos
|
self.lastPos = toonPos
|
||||||
return Task.cont
|
return task.cont
|
||||||
|
|
||||||
def __handleHeading(self, xVel, yVel):
|
def __handleHeading(self, xVel, yVel):
|
||||||
def getHeading(xVel, yVel):
|
def getHeading(xVel, yVel):
|
||||||
|
@ -144,7 +152,7 @@ class TwoDDrive:
|
||||||
if ((self.lastXVel and self.lastYVel) and not (xVel and yVel)):
|
if ((self.lastXVel and self.lastYVel) and not (xVel and yVel)):
|
||||||
def setAtRestHeading(task, self = self, angle = curHeading):
|
def setAtRestHeading(task, self = self, angle = curHeading):
|
||||||
self.atRestHeading = angle
|
self.atRestHeading = angle
|
||||||
return Task.done
|
return task.done
|
||||||
|
|
||||||
taskMgr.doMethodLater(0.05, setAtRestHeading, TwoDDrive.SET_ATREST_HEADING_TASK)
|
taskMgr.doMethodLater(0.05, setAtRestHeading, TwoDDrive.SET_ATREST_HEADING_TASK)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
from .ToonBase import *
|
__all__ = ['base']
|
||||||
|
|
||||||
|
from .ToonBase import ToonBase
|
||||||
|
|
||||||
|
base = ToonBase()
|
||||||
|
|
|
@ -6,7 +6,20 @@ class game:
|
||||||
|
|
||||||
|
|
||||||
builtins.game = 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 time
|
||||||
import sys
|
import sys
|
||||||
try:
|
try:
|
||||||
|
@ -38,8 +51,7 @@ print('ToontownStart: setting default font')
|
||||||
from . import ToontownGlobals
|
from . import ToontownGlobals
|
||||||
DirectGuiGlobals.setDefaultFontFunc(ToontownGlobals.getInterfaceFont)
|
DirectGuiGlobals.setDefaultFontFunc(ToontownGlobals.getInterfaceFont)
|
||||||
launcher.setPandaErrorCode(7)
|
launcher.setPandaErrorCode(7)
|
||||||
from . import ToonBase
|
from .ToonBaseGlobal import base
|
||||||
ToonBase.ToonBase()
|
|
||||||
if base.win == None:
|
if base.win == None:
|
||||||
print('Unable to open window; aborting.')
|
print('Unable to open window; aborting.')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
@ -70,21 +82,19 @@ if base.musicManagerIsValid:
|
||||||
DirectGuiGlobals.setDefaultClickSound(base.loader.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
|
DirectGuiGlobals.setDefaultClickSound(base.loader.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
|
||||||
else:
|
else:
|
||||||
music = None
|
music = None
|
||||||
from direct.gui.DirectGui import *
|
from direct.gui.DirectGui import OnscreenText
|
||||||
serverVersion = ConfigVariableString('server-version', 'no_version_set').value
|
serverVersion = ConfigVariableString('server-version', 'no_version_set').value
|
||||||
print('ToontownStart: serverVersion: ', serverVersion)
|
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)
|
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)
|
loader.beginBulkLoad('init', TTLocalizer.LoaderLabel, 138, 0, TTLocalizer.TIP_NONE)
|
||||||
from .ToonBaseGlobal import *
|
from toontown.distributed.ToontownClientRepository import ToontownClientRepository
|
||||||
from direct.showbase.MessengerGlobal import *
|
cr = ToontownClientRepository(serverVersion, launcher)
|
||||||
from toontown.distributed import ToontownClientRepository
|
|
||||||
cr = ToontownClientRepository.ToontownClientRepository(serverVersion, launcher)
|
|
||||||
cr.music = music
|
cr.music = music
|
||||||
del music
|
del music
|
||||||
base.initNametagGlobals()
|
base.initNametagGlobals()
|
||||||
base.cr = cr
|
base.cr = cr
|
||||||
loader.endBulkLoad('init')
|
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')
|
cr.generateGlobalObject(OTP_DO_ID_FRIEND_MANAGER, 'FriendManager')
|
||||||
if not launcher.isDummy():
|
if not launcher.isDummy():
|
||||||
base.startShow(cr, launcher.getGameServer())
|
base.startShow(cr, launcher.getGameServer())
|
||||||
|
@ -97,7 +107,6 @@ del backgroundNode
|
||||||
del tempLoader
|
del tempLoader
|
||||||
version.cleanup()
|
version.cleanup()
|
||||||
del version
|
del version
|
||||||
base.loader = base.loader
|
|
||||||
builtins.loader = base.loader
|
builtins.loader = base.loader
|
||||||
autoRun = ConfigVariableBool('toontown-auto-run', 1)
|
autoRun = ConfigVariableBool('toontown-auto-run', 1)
|
||||||
if autoRun and launcher.isDummy() and (not Thread.isTrueThreads() or __name__ == '__main__'):
|
if autoRun and launcher.isDummy() and (not Thread.isTrueThreads() or __name__ == '__main__'):
|
||||||
|
|
Loading…
Reference in a new issue