Compare commits
No commits in common. "77b9d05823b6f334f16cbba06a457aebe3c393ed" and "2a431f509f0f0e66cfb99905cbf2938213bef7dc" have entirely different histories.
77b9d05823
...
2a431f509f
@ -4,7 +4,6 @@ import npyscreen
|
|||||||
|
|
||||||
from npytabletracker.ui import TableTrackerDisplay
|
from npytabletracker.ui import TableTrackerDisplay
|
||||||
|
|
||||||
|
|
||||||
class TableTrackerApplication(npyscreen.NPSAppManaged):
|
class TableTrackerApplication(npyscreen.NPSAppManaged):
|
||||||
"""Combine the pieces of the application."""
|
"""Combine the pieces of the application."""
|
||||||
|
|
||||||
@ -12,6 +11,5 @@ class TableTrackerApplication(npyscreen.NPSAppManaged):
|
|||||||
"""Link necessary UI elements and state management and whatnot."""
|
"""Link necessary UI elements and state management and whatnot."""
|
||||||
self.addForm('MAIN', TableTrackerDisplay)
|
self.addForm('MAIN', TableTrackerDisplay)
|
||||||
|
|
||||||
|
|
||||||
app = TableTrackerApplication()
|
app = TableTrackerApplication()
|
||||||
app.run()
|
app.run()
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
"""ActionController for command processing."""
|
|
||||||
import re
|
|
||||||
|
|
||||||
import npyscreen
|
|
||||||
|
|
||||||
|
|
||||||
class ManagementActionController(npyscreen.ActionControllerSimple):
|
|
||||||
"""Process commands from the command line and act on them."""
|
|
||||||
|
|
||||||
ADD_REGEX = r'^/add (.*)$'
|
|
||||||
TITLE_REGEX = r'^/title (.*)$'
|
|
||||||
|
|
||||||
def create(self):
|
|
||||||
"""Hook command handlers."""
|
|
||||||
self.add_action(self.ADD_REGEX, self.add_character, False)
|
|
||||||
self.add_action(self.TITLE_REGEX, self.title, False)
|
|
||||||
|
|
||||||
def add_character(self, command_line, widget_proxy, live):
|
|
||||||
"""Add a character to the list."""
|
|
||||||
match = re.search(self.ADD_REGEX, command_line, re.IGNORECASE)
|
|
||||||
self.parent.value.characters.append(match.group(1))
|
|
||||||
self.parent.wMain.values = self.parent.value.characters
|
|
||||||
self.parent.wMain.display()
|
|
||||||
|
|
||||||
def title(self, command_line, widget_proxy, live):
|
|
||||||
"""Set the title in the top status bar."""
|
|
||||||
match = re.search(self.TITLE_REGEX, command_line, re.IGNORECASE)
|
|
||||||
self.parent.wStatus1.value = match.group(1)
|
|
||||||
self.parent.wStatus1.display()
|
|
@ -1,9 +0,0 @@
|
|||||||
"""Maintain state in an object for use as a DATA_CONTROLLER."""
|
|
||||||
|
|
||||||
|
|
||||||
class TableState(object):
|
|
||||||
"""Track character initiative, hit points, etc."""
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
"""Initialize data."""
|
|
||||||
self.characters = []
|
|
@ -1,47 +1,6 @@
|
|||||||
"""UI elements for the npytabletracker application."""
|
"""UI elements for the npytabletracker application."""
|
||||||
import npyscreen
|
import npyscreen
|
||||||
|
|
||||||
from npytabletracker.cmd import ManagementActionController
|
|
||||||
from npytabletracker.data import TableState
|
|
||||||
|
|
||||||
|
|
||||||
class CharacterList(npyscreen.MultiLineAction):
|
|
||||||
"""Display characters' initiative order and allow for operations on them."""
|
|
||||||
|
|
||||||
def __init__(self, *args, **keywords):
|
|
||||||
"""Set up some extra handlers when selecting characters in the list."""
|
|
||||||
super(CharacterList, self).__init__(*args, **keywords)
|
|
||||||
self.add_handlers({
|
|
||||||
">": self.when_init_move_down,
|
|
||||||
"<": self.when_init_move_up
|
|
||||||
})
|
|
||||||
|
|
||||||
def when_init_move_down(self, *args, **keywords):
|
|
||||||
"""Move the selected character down one spot in the initiative table."""
|
|
||||||
if self.cursor_line < len(self.parent.value.characters) - 1:
|
|
||||||
chars = self.parent.value.characters
|
|
||||||
pos = self.cursor_line
|
|
||||||
chars[pos], chars[pos+1] = chars[pos+1], chars[pos]
|
|
||||||
self.parent.update_list()
|
|
||||||
self.cursor_line += 1
|
|
||||||
|
|
||||||
def when_init_move_up(self, *args, **keywords):
|
|
||||||
"""Move the selected character up one spot in the initiative table."""
|
|
||||||
if self.cursor_line - 1 >= 0:
|
|
||||||
chars = self.parent.value.characters
|
|
||||||
pos = self.cursor_line
|
|
||||||
chars[pos], chars[pos-1] = chars[pos-1], chars[pos]
|
|
||||||
self.parent.update_list()
|
|
||||||
self.cursor_line -= 1
|
|
||||||
|
|
||||||
|
|
||||||
class TableTrackerDisplay(npyscreen.FormMuttActiveTraditional):
|
class TableTrackerDisplay(npyscreen.FormMuttActiveTraditional):
|
||||||
"""Create the high level form, which is organized like mutt/irssi."""
|
"""Create the high level form, which is organized like mutt/irssi."""
|
||||||
|
pass
|
||||||
ACTION_CONTROLLER = ManagementActionController
|
|
||||||
DATA_CONTROLER = TableState
|
|
||||||
MAIN_WIDGET_CLASS = CharacterList
|
|
||||||
|
|
||||||
def update_list(self):
|
|
||||||
"""Update data in the window and represent it."""
|
|
||||||
self.wMain.display()
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
-r requirements.in
|
-r requirements.in
|
||||||
|
|
||||||
flake8
|
|
||||||
pip-tools
|
pip-tools
|
||||||
|
@ -5,11 +5,6 @@
|
|||||||
# pip-compile --output-file=requirements/requirements-dev.txt requirements/requirements-dev.in
|
# pip-compile --output-file=requirements/requirements-dev.txt requirements/requirements-dev.in
|
||||||
#
|
#
|
||||||
click==7.0 # via pip-tools
|
click==7.0 # via pip-tools
|
||||||
entrypoints==0.3 # via flake8
|
|
||||||
flake8==3.7.9
|
|
||||||
mccabe==0.6.1 # via flake8
|
|
||||||
npyscreen==4.10.5
|
npyscreen==4.10.5
|
||||||
pip-tools==4.4.1
|
pip-tools==4.4.1
|
||||||
pycodestyle==2.5.0 # via flake8
|
|
||||||
pyflakes==2.1.1 # via flake8
|
|
||||||
six==1.14.0 # via pip-tools
|
six==1.14.0 # via pip-tools
|
||||||
|
Loading…
x
Reference in New Issue
Block a user