Commits

Alex Mayfield committed 081c144

First round of ZDaemon -> Odamex text conversion. Also pass correct params to Odamex.

  • Participants
  • Parent commits 8c9c00d

Comments (0)

Files changed (1)

 from ZDStack.Utils import get_event_from_line, resolve_path, \
                           timedelta_in_seconds
 
-APP_AUTHOR = 'Charlie Gunyon'
-APP_NAME = 'ZDStats'
+APP_AUTHOR = 'Charlie Gunyon & Alex Mayfield'
+APP_NAME = 'OdaStats'
 IDL_HOST = 'www.intldoomleague.org'
 IDL_PORT = 80
 
 def get_datetime_filename(extension=None):
     now = datetime.datetime.now()
     if extension:
-        return '.'.join((now.strftime('zdstats-%Y%m%d_%H%M%S'), extension))
+        return '.'.join((now.strftime('odastats-%Y%m%d_%H%M%S'), extension))
     else:
-        return now.strftime('zdstats-%Y%m%d_%H%M%S')
+        return now.strftime('odastats-%Y%m%d_%H%M%S')
 
 class InputLog(object):
 
         self.mainLayout = QHBoxLayout()
         self.leftLayout = QVBoxLayout()
         self.rightLayout = QVBoxLayout()
-        self.zdaemonLayout = QHBoxLayout()
+        self.odamexLayout = QHBoxLayout()
         self.outputFolderLayout = QHBoxLayout()
         self.wadFolderLayout = QHBoxLayout()
         self.demoLayout = QHBoxLayout()
         self.mainPanel = QWidget()
         self.leftPanel = QWidget()
         self.rightPanel = QWidget()
-        self.zdaemonPanel = QWidget()
+        self.odamexPanel = QWidget()
         self.outputFolderPanel = QWidget()
         self.wadFolderPanel = QWidget()
         self.demoPanel = QWidget()
         self.serverPanel = QWidget()
-        self.zdaemonPathLabel = QLabel('Path to ZDaemon:')
-        self.zdaemonPathInput = QLineEdit()
-        self.zdaemonPathInput.setReadOnly(True)
-        self.zdaemonBrowseButton = QPushButton('Browse')
-        self.zdaemonLayout.addWidget(self.zdaemonPathLabel)
-        self.zdaemonLayout.addWidget(self.zdaemonPathInput)
-        self.zdaemonLayout.addWidget(self.zdaemonBrowseButton)
-        self.zdaemonPanel.setLayout(self.zdaemonLayout)
+        self.odamexPathLabel = QLabel('Path to Odamex:')
+        self.odamexPathInput = QLineEdit()
+        self.odamexPathInput.setReadOnly(True)
+        self.odamexBrowseButton = QPushButton('Browse')
+        self.odamexLayout.addWidget(self.odamexPathLabel)
+        self.odamexLayout.addWidget(self.odamexPathInput)
+        self.odamexLayout.addWidget(self.odamexBrowseButton)
+        self.odamexPanel.setLayout(self.odamexLayout)
         self.outputFolderLabel = QLabel('Output Folder:')
         self.outputFolderInput = QLineEdit()
         self.outputFolderInput.setReadOnly(True)
         self.serverListLayout.addWidget(self.serverList)
         self.serverListLayout.addWidget(self.serverJoinButton)
         self.serverPanel.setLayout(self.serverListLayout)
-        self.leftLayout.addWidget(self.zdaemonPanel)
+        self.leftLayout.addWidget(self.odamexPanel)
         self.leftLayout.addWidget(self.outputFolderPanel)
         self.leftLayout.addWidget(self.wadFolderPanel)
         self.leftLayout.addWidget(self.demoPanel)
         self.mainPanel.setLayout(self.mainLayout)
         self.setCentralWidget(self.mainPanel)
         self.readSettings()
-        self.zdaemonBrowseButton.clicked.connect(self.setZDaemon)
+        self.odamexBrowseButton.clicked.connect(self.setOdamex)
         self.outputFolderBrowseButton.clicked.connect(self.setOutputFolder)
         self.outputFolderOpenButton.clicked.connect(self.openOutputFolder)
         self.wadFolderBrowseButton.clicked.connect(self.setWADFolder)
         settings = QSettings(APP_AUTHOR, APP_NAME)
         pos = settings.value('pos', QPoint(200, 200))
         size = settings.value('size', QSize(800, 240))
-        zdaemon = settings.value('zdaemon', None)
+        odamex = settings.value('odamex', None)
         output_folder = settings.value('output_folder', None)
         wad_folder = settings.value('wad_folder', None)
         self.resize(QSize(800, 240))
         self.move(pos)
-        if zdaemon:
-            self.zdaemonPathInput.setText(zdaemon)
+        if odamex:
+            self.odamexPathInput.setText(odamex)
         if output_folder:
             self.outputFolderInput.setText(output_folder)
         if wad_folder:
         settings = QSettings(APP_AUTHOR, APP_NAME)
         settings.setValue('pos', self.pos())
         settings.setValue('size', self.size())
-        zdaemon = self.zdaemonPathInput.text()
+        odamex = self.odamexPathInput.text()
         output_folder = self.outputFolderInput.text()
         wad_folder = self.wadFolderInput.text()
-        if zdaemon:
-            settings.setValue('zdaemon', zdaemon)
+        if odamex:
+            settings.setValue('odamex', odamex)
         if output_folder:
             settings.setValue('output_folder', output_folder)
         if wad_folder:
             settings.setValue('wad_folder', wad_folder)
 
-    def setZDaemon(self):
+    def setOdamex(self):
         filename, filtr = QFileDialog.getOpenFileName(
             self,
-            'Set Path to ZDaemon',
+            'Set Path to Odamex',
             '.',
             'Programs (*.exe);;All files (*.*)'
         )
         if filename:
             filename = fix_slashes(filename)
-            self.statusMessage('Set ZDaemon executable to "%s".' % (filename))
-            self.zdaemonPathInput.setText(filename)
+            self.statusMessage('Set Odamex executable to "%s".' % (filename))
+            self.odamexPathInput.setText(filename)
 
     def setWADFolder(self):
         foldername = QFileDialog.getExistingDirectory(
     def loadDemo(self):
         filename, filtr = QFileDialog.getOpenFileName(
             self,
-            'Open ZDaemon Demo',
+            'Open Odamex Demo',
             '.',
-            'ZDaemon Demo File (*.zdo);;All files (*.*)'
+            'Odamex Demo File (*.odd);;All files (*.*)'
         )
         if filename:
             filename = fix_slashes(filename)
             self.demoInput.setText(filename)
             self.statusMessage('Loaded demo "%s".' % (filename))
 
-    def getStats(self, zdaemon_log_path):
+    def getStats(self, odamex_log_path):
         from ZDStack.ZDSRegexps import get_client_regexps
         # [CG] We can safely assume the output folder input field is populated
         #      because this function is only called after the field is checked.
             self.outputFolderInput.text(),
             get_datetime_filename(extension='json')
         )
-        while not os.path.isfile(zdaemon_log_path):
+        while not os.path.isfile(odamex_log_path):
             time.sleep(1)
-        input_logfile = InputLog(zdaemon_log_path)
+        input_logfile = InputLog(odamex_log_path)
         output_logfile = OutputLog(event_log_path)
         regexps = get_client_regexps()
         epoch = datetime.datetime(1970, 1, 1)
         while 1:
-            if self.zdaemon_pobj.poll() is not None:
+            if self.odamex_pobj.poll() is not None:
                 output_logfile.close()
                 self.statusMessage('Events saved to %s.' % (event_log_path))
                 break
             else:
                 time.sleep(.027)
 
-    def launchZDaemon(self, extra_args=None):
-        zdaemon = self.zdaemonPathInput.text()
-        if not zdaemon:
-            self.statusMessage('ZDaemon path not set.')
+    def launchOdamex(self, extra_args=None):
+        odamex = self.odamexPathInput.text()
+        if not odamex:
+            self.statusMessage('Odamex path not set.')
             return
         output_folder = self.outputFolderInput.text()
         if not output_folder:
         if not os.path.isfile(iwad_path):
             self.statusMessage('doom2.wad not found in %s.' % (wad_folder))
             return
-        zdaemon_log_file = get_datetime_filename(extension='txt')
-        zdaemon_log_path = os.path.join(output_folder, zdaemon_log_file)
-        zvox_wad_path = os.path.join(wad_folder, 'zvox2.wad')
+        odamex_log_file = get_datetime_filename(extension='txt')
+        odamex_log_path = os.path.join(output_folder, odamex_log_file)
         cmd_args = [
-            zdaemon,
+            odamex,
             '-iwad', iwad_path,
-            '-file', zvox_wad_path,
-            '+logfile', zdaemon_log_path
+            '+logfile', odamex_log_path
         ]
         if extra_args:
             cmd_args.extend(extra_args)
-        self.statusMessage('Launching ZDaemon.')
+        self.statusMessage('Launching Odamex.')
         print ' '.join(cmd_args)
-        self.zdaemon_pobj = subprocess.Popen(cmd_args)
+        self.odamex_pobj = subprocess.Popen(cmd_args)
         self.statusMessage('Gathering events.')
-        self.getStats(zdaemon_log_path)
+        self.getStats(odamex_log_path)
 
     def playDemo(self):
         demo_path = self.demoInput.text()
             self.statusMessage('WAD folder not set.')
             return
         demo_file = os.path.basename(demo_path).lower()
-        args = ['+netplay', demo_path]
-        wads = [f for f in os.listdir(wad_folder) if f.lower().endswith('wad')]
-        for wad in wads:
-            if wad[:-4].lower() in demo_file:
-                wad_path = os.path.join(wad_folder, wad)
-                args.extend(['-file', wad_path])
-        if '-file' not in args:
-            self.statusMessage(
-                'No WADs indicated in demo filename, rename it appropriately.'
-            )
-            return
-        self.launchZDaemon(args)
+        args = ['-waddir', wad_folder, '+netplay', demo_path]
+        self.launchOdamex(args)
 
     def connectToServer(self):
         output_folder = self.outputFolderInput.text()
             return
         demo_path = os.path.join(output_folder, get_datetime_filename('zdo'))
         idl_wad_path = os.path.join(wad_folder, self.seasonWAD)
-        self.launchZDaemon((
+        self.launchOdamex((
             '-connect', server.address,
             '-file', idl_wad_path,
             '-netrecord', demo_path,