general: Some small fixes

This commit is contained in:
Open Toontown 2019-11-08 20:23:35 -05:00
parent 4ae72453e7
commit f497c3d011
5 changed files with 62 additions and 7 deletions

1
astron/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
bin/

View file

@ -64,9 +64,9 @@ class LoginScreen(StateData.StateData, GuiScreen.GuiScreen):
linePos -= buttonLineHeight
self.dialogDoneEvent = 'loginDialogAck'
dialogClass = OTPGlobals.getGlobalDialogClass()
self.dialog = dialogClass(dialogName='loginDialog', doneEvent=self.dialogDoneEvent, message='', style=OTPDialog.Acknowledge, sortOrder=NO_FADE_SORT_INDEX + 100)
self.dialog = dialogClass(dialogName='loginDialog', doneEvent=self.dialogDoneEvent, message='', style=OTPDialog.Acknowledge, sortOrder=DGG.NO_FADE_SORT_INDEX + 100)
self.dialog.hide()
self.failDialog = DirectFrame(parent=aspect2dp, relief=DGG.RAISED, borderWidth=(0.01, 0.01), pos=(0, 0.1, 0), text='', text_scale=0.08, text_pos=(0.0, 0.3), text_wordwrap=15, sortOrder=NO_FADE_SORT_INDEX)
self.failDialog = DirectFrame(parent=aspect2dp, relief=DGG.RAISED, borderWidth=(0.01, 0.01), pos=(0, 0.1, 0), text='', text_scale=0.08, text_pos=(0.0, 0.3), text_wordwrap=15, sortOrder=DGG.NO_FADE_SORT_INDEX)
linePos = -.05
self.failTryAgainButton = DirectButton(parent=self.failDialog, relief=DGG.RAISED, borderWidth=(0.01, 0.01), pos=(0, 0, linePos), scale=0.9, text=OTPLocalizer.LoginScreenTryAgain, text_scale=0.06, text_pos=(0, -.02), command=self.__handleFailTryAgain)
linePos -= buttonLineHeight
@ -75,7 +75,7 @@ class LoginScreen(StateData.StateData, GuiScreen.GuiScreen):
self.failDialog.hide()
self.connectionProblemDialogDoneEvent = 'loginConnectionProblemDlgAck'
dialogClass = OTPGlobals.getGlobalDialogClass()
self.connectionProblemDialog = dialogClass(dialogName='connectionProblemDialog', doneEvent=self.connectionProblemDialogDoneEvent, message='', style=OTPDialog.Acknowledge, sortOrder=NO_FADE_SORT_INDEX + 100)
self.connectionProblemDialog = dialogClass(dialogName='connectionProblemDialog', doneEvent=self.connectionProblemDialogDoneEvent, message='', style=OTPDialog.Acknowledge, sortOrder=DGG.NO_FADE_SORT_INDEX + 100)
self.connectionProblemDialog.hide()
return

View file

@ -1,4 +1,7 @@
import __builtin__
import sys
__all__ = ['describeException', 'pdir']
# class 'decorator' that records the stack at the time of creation
# be careful with this, it creates a StackTrace, and that can take a
@ -22,6 +25,56 @@ def recordCreationStack(cls):
cls.printCreationStackTrace = printCreationStackTrace
return cls
def describeException(backTrace = 4):
# When called in an exception handler, returns a string describing
# the current exception.
def byteOffsetToLineno(code, byte):
# Returns the source line number corresponding to the given byte
# offset into the indicated Python code module.
import array
lnotab = array.array('B', code.co_lnotab)
line = code.co_firstlineno
for i in range(0, len(lnotab), 2):
byte -= lnotab[i]
if byte <= 0:
return line
line += lnotab[i+1]
return line
infoArr = sys.exc_info()
exception = infoArr[0]
exceptionName = getattr(exception, '__name__', None)
extraInfo = infoArr[1]
trace = infoArr[2]
stack = []
while trace.tb_next:
# We need to call byteOffsetToLineno to determine the true
# line number at which the exception occurred, even though we
# have both trace.tb_lineno and frame.f_lineno, which return
# the correct line number only in non-optimized mode.
frame = trace.tb_frame
module = frame.f_globals.get('__name__', None)
lineno = byteOffsetToLineno(frame.f_code, frame.f_lasti)
stack.append("%s:%s, " % (module, lineno))
trace = trace.tb_next
frame = trace.tb_frame
module = frame.f_globals.get('__name__', None)
lineno = byteOffsetToLineno(frame.f_code, frame.f_lasti)
stack.append("%s:%s, " % (module, lineno))
description = ""
for i in range(len(stack) - 1, max(len(stack) - backTrace, 0) - 1, -1):
description += stack[i]
description += "%s: %s" % (exceptionName, extraInfo)
return description
def pdir(obj, str = None, width = None,
fTruncate = 1, lineWidth = 75, wantPrivate = 0):
# Remove redundant class entries

View file

@ -148,7 +148,7 @@ class ToonBase(OTPBase.OTPBase):
self.canScreenShot = 1
self.glitchCount = 0
self.walking = 0
self.resetMusic = self.loadMusic('phase_3/audio/bgm/MIDI_Events_16channels.mid')
self.resetMusic = self.loader.loadMusic('phase_3/audio/bgm/MIDI_Events_16channels.mid')
self.oldX = max(1, base.win.getXSize())
self.oldY = max(1, base.win.getYSize())
self.aspectRatio = float(self.oldX) / self.oldY
@ -308,11 +308,12 @@ class ToonBase(OTPBase.OTPBase):
self.notify.info('Using gameServer from launcher: %s ' % gameServer)
else:
gameServer = 'localhost'
serverPort = base.config.GetInt('server-port', 6667)
serverPort = base.config.GetInt('server-port', 7198)
serverList = []
for name in gameServer.split(';'):
url = URLSpec(name, 1)
url.setScheme('s')
if config.GetBool('server-want-ssl', False):
url.setScheme('s')
if not url.hasPort():
url.setPort(serverPort)
serverList.append(url)

View file

@ -112,6 +112,6 @@ if autoRun and launcher.isDummy() and (not Thread.isTrueThreads() or __name__ ==
except SystemExit:
raise
except:
from direct.showbase import PythonUtil
from otp.otpbase import PythonUtil
print PythonUtil.describeException()
raise