def parse(self, timestamp, text): """Parse casting triggers (casting, failure, success).""" # custom timers if config.data['spells']['use_custom_triggers']: for rx, ct in self._custom_timers.items(): if rx.match(text): spell = Spell( name=ct.name, duration=int(text_time_to_seconds(ct.time) / 6), duration_formula=11, # honour duration ticks spell_icon=14) self._spell_container.add_spell(spell, timestamp, '__custom__') if self._spell_trigger: self._spell_trigger.parse(timestamp, text) # Initial Spell Cast and trigger setup if text[:17] == 'You begin casting': spell = self.spell_book.get(text[18:-1], None) if spell and spell.duration_formula != 0: self._spell_triggered( ) # in case we cut off the cast window, force trigger self._remove_spell_trigger() spell_trigger = SpellTrigger(spell=spell, timestamp=timestamp) spell_trigger.spell_triggered.connect(self._spell_triggered) self._spell_trigger = spell_trigger # Spell Interrupted elif (self._spell_triggers and text[:26] == 'Your spell is interrupted.' or text[:20] == 'Your target resisted' or text[:29] == 'Your spell did not take hold.' or text[:26] == 'You try to cast a spell on'): self._remove_spell_trigger() # Elongate self buff timers by time zoning elif text[:23] == 'LOADING, PLEASE WAIT...': self._spell_triggered() self._remove_spell_trigger() self._zoning = timestamp spell_target = self._spell_container.get_spell_target_by_name( '__you__') if spell_target: for spell_widget in spell_target.spell_widgets(): spell_widget.pause() elif self._zoning and text[:16] == 'You have entered': delay = (timestamp - self._zoning).total_seconds() spell_target = self._spell_container.get_spell_target_by_name( '__you__') if spell_target: for spell_widget in spell_target.spell_widgets(): spell_widget.elongate(delay) spell_widget.resume()
def _save_trigger(self): if self._trigger_name.text(): # validate text and time if self._trigger_text.text() and\ text_time_to_seconds(self._trigger_time.text()): if self._trigger_name.text() in self._custom_triggers.keys() and \ not self._trigger_name.text() == self._current_trigger: m = QMessageBox() m.setText("A custom trigger with this name already exists.") m.exec() elif not self._trigger_name.text() == self._current_trigger and \ not self._current_trigger == '': # update name and info ct = self._custom_triggers.pop(self._current_trigger) ct.name = self._trigger_name.text() ct.text = self._trigger_text.text() ct.time = self._trigger_time.text() ct.on_you = self._trigger_on_you.isChecked() self._custom_triggers[ct.name] = ct elif self._current_trigger == '': # new trigger ct = CustomTrigger( self._trigger_name.text(), self._trigger_text.text(), self._trigger_time.text(), False ) self._custom_triggers[ct.name] = ct else: # update ct = self._custom_triggers[self._current_trigger] ct.text = self._trigger_text.text() ct.time = self._trigger_time.text() ct.on_you = self._trigger_on_you.isChecked() self._custom_triggers[self._current_trigger] = ct # save and reload current_index = self._triggers.currentIndex() self._save_to_config() self._load_from_config() self._triggers.setCurrentIndex(current_index) self._activated(None) else: m = QMessageBox() m.setText("Both the text and time (hh:mm:ss) need to be filled out.") m.exec()
def contextMenuEvent(self, event): # create menu pos = self.mapToScene(event.pos()) menu = QMenu(self) # remove from memory after usage menu.setAttribute(Qt.WA_DeleteOnClose) # remove from memory spawn_point_menu = menu.addMenu('Spawn Point') spawn_point_create = spawn_point_menu.addAction('Create on Cursor') spawn_point_delete = spawn_point_menu.addAction('Delete on Cursor') spawn_point_delete_all = spawn_point_menu.addAction('Delete All') way_point_menu = menu.addMenu('Way Point') way_point_create = way_point_menu.addAction('Create on Cursor') way_point_delete = way_point_menu.addAction('Clear') load_map = menu.addAction('Load Map') # execute action = menu.exec_(self.mapToGlobal(event.pos())) # parse response if action == spawn_point_create: spawn_time = text_time_to_seconds('6:40') dialog = QInputDialog(self) dialog.setWindowTitle('Create Spawn Point') dialog.setLabelText('Respawn Time (hh:mm:ss):') dialog.setTextValue('6:40') if dialog.exec_(): spawn_time = text_time_to_seconds(dialog.textValue()) dialog.deleteLater() spawn = SpawnPoint(location=MapPoint( x=pos.x(), y=pos.y(), z=self._data.geometry.z_groups[self._z_index]), length=spawn_time) self._scene.addItem(spawn) self._data.spawns.append(spawn) spawn.start() if action == spawn_point_delete: pixmap = self._scene.itemAt(pos.x(), pos.y(), QTransform()) if pixmap: group = pixmap.parentItem() if group: self._data.spawns.remove(group) self._scene.removeItem(group) if action == spawn_point_delete_all: for spawn in self._data.spawns: self._scene.removeItem(spawn) self._data.spawns = [] if action == way_point_create: if self._data.way_point: self._scene.removeItem(self._data.way_point.pixmap) self._scene.removeItem(self._data.way_point.line) self._data.way_point = None self._data.way_point = WayPoint(location=MapPoint( x=pos.x(), y=pos.y(), z=self._data.geometry.z_groups[self._z_index])) self._scene.addItem(self._data.way_point.pixmap) self._scene.addItem(self._data.way_point.line) if action == way_point_delete: if self._data.way_point: self._scene.removeItem(self._data.way_point.pixmap) self._scene.removeItem(self._data.way_point.line) self._data.way_point = None if action == load_map: dialog = QInputDialog(self) dialog.setWindowTitle('Load Map') dialog.setLabelText('Select map to load:') dialog.setComboBoxItems( sorted([map.title() for map in MapData.get_zone_dict().keys()])) if dialog.exec_(): self.load_map(dialog.textValue().lower()) dialog.deleteLater() self.update_()
def parse(self, timestamp, text, charname): """Parse casting triggers (casting, failure, success).""" self.logstreamer.setCharacterName(charname) self.logstreamer.stream(timestamp, text) self.updateCharacterName(charname) # custom timers if config.data['spells']['use_custom_triggers']: cvt = self.cvtrx.match(text) if cvt and len(cvt.groups()) == 2: name = cvt.groups()[0].replace("_", " ") ts = cvt.groups()[1] ts = ts[0:2] + ":" + ts[2:4] + ":" + ts[4:6] spell = Spell(name=name, duration=int(text_time_to_seconds(ts) / 6), duration_formula=11, spell_icon=14) self._spell_container.add_spell(spell, timestamp, '__custom__') for rx, ct in self._custom_timers.items(): if rx.match(text): spell = Spell( name=ct.name, duration=int(text_time_to_seconds(ct.time) / 6), duration_formula=11, # honour duration ticks spell_icon=14) self._spell_container.add_spell( spell, timestamp, '__you__' if ct.on_you else '__custom__') if self._spell_trigger: self._spell_trigger.parse(timestamp, text) # Initial Spell Cast and trigger setup if text[:17] == 'You begin casting': spell = self.spell_book.get(text[18:-1], None) if spell and spell.duration_formula != 0: self._spell_triggered( ) # in case we cut off the cast window, force trigger self._remove_spell_trigger() spell_trigger = SpellTrigger(spell=spell, timestamp=timestamp) spell_trigger.spell_triggered.connect(self._spell_triggered) self._spell_trigger = spell_trigger # Spell Interrupted elif (self._spell_triggers and text[:26] == 'Your spell is interrupted.' or text[:20] == 'Your target resisted' or text[:29] == 'Your spell did not take hold.' or text[:26] == 'You try to cast a spell on'): self._remove_spell_trigger() # Elongate self buff timers by time zoning elif text[:23] == 'LOADING, PLEASE WAIT...': self._spell_triggered() self._remove_spell_trigger() self._zoning = timestamp spell_target = self._spell_container.get_spell_target_by_name( '__you__') if spell_target: for spell_widget in spell_target.spell_widgets(): spell_widget.pause() elif self._zoning and text[:16] == 'You have entered': spell_target = self._spell_container.get_spell_target_by_name( '__you__') if spell_target: for spell_widget in spell_target.spell_widgets(): spell_widget.resume()