Skip to content

Commit f72715b

Browse files
author
Tim-ats-d
committed
Removing init_visualdialog function of automatic import, delay time between each characters has been now set to 0.04 by default, delay time between each downtime_characters has been now set to 0.6 by default, some minors changes typography changes to respect PEP8 in core.py, example file are now contained in doc/examples folder, renaming the file monologue_example.py to monologue.py, some clarifications and improvements in examples files(monologue.py confrontation.py).
1 parent d14548f commit f72715b

File tree

5 files changed

+31
-36
lines changed

5 files changed

+31
-36
lines changed

doc/confrontation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import curses
55

6-
from visualdialog import *
6+
from visualdialog import DialogBox
77

88

99
def main(stdscr):
@@ -38,7 +38,7 @@ def main(stdscr):
3838
)
3939

4040
# Definition of accepted key codes to pass a dialog.
41-
# See documentation of the curses constants for more informations.
41+
# See documentation of curses constants for more informations.
4242
phoenix_textbox.confirm_dialog_key = (10, 32) # Key Enter and Space.
4343
april_may_textbox.confirm_dialog_key = (10, 32) # Key Enter and Space.
4444
edgeworth_textbox.confirm_dialog_key = (10, 32) # Key Enter and Space.

doc/monologue_example.py renamed to doc/monologue.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
import curses
55

6-
from visualdialog import *
6+
from visualdialog import DialogBox
77

88

99
def main(stdscr):
10-
text = (
11-
"Hello world",
12-
"How are you today ?",
13-
"Press a key to skip this dialog."
10+
replys = (
11+
"Hello world, how are you today ?",
12+
"Press a key to skip this dialog.",
13+
"That is a basic example.",
14+
"See doc for more informations."
1415
)
1516

1617
# Makes the cursor invisible.
@@ -32,15 +33,15 @@ def main(stdscr):
3233
textbox.confirm_dialog_key = (10, 32) # Key Enter and Space.
3334

3435
# Display each sentence contains in text.
35-
for reply in text:
36+
for reply in replys:
3637
textbox.char_by_char(stdscr,
3738
reply,
3839
2, # Display of the reply variable colored with color pair 2.
39-
delay=0.05
40-
)
40+
delay=0.04) # Set delay between each characters to 0.04 seconde.
4141

4242
textbox.getkey(stdscr) # Waiting for a key press.
43-
stdscr.clear() # Clear the screen.
43+
stdscr.clear() # Clear the screen.
44+
4445

4546
# Execution of the function.
4647
curses.wrapper(main)

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
packages=find_packages(),
1111
author="Arnouts Timéo",
1212
author_email="[email protected]",
13-
description="A librairie which provides class and functions to make easier dialog box in terminal.",
13+
description="A librairie to make easier dialog box in terminal.",
1414
long_description=open("README.md").read(),
1515
include_package_data=True,
1616
url="https://github.com/Tim-ats-d/Visual-dialog",
@@ -35,6 +35,5 @@
3535
"Programming Language :: Python :: 3.9",
3636
"Programming Language :: Python :: Implementation",
3737
"Topic :: Games/Entertainment :: Role-Playing",
38-
"Topic :: Software Development :: Libraries :: Python Modules",
39-
"Topic :: Software Development :: Libraries :: pygame"]
38+
"Topic :: Software Development :: Libraries :: Python Modules"]
4039
)

visualdialog/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88
__version__ = 0.2
99

1010
from .core import DialogBox
11-
from .core import init_visualdialog

visualdialog/core.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,33 @@
2121
#
2222
#
2323

24-
__all__ = ["init_visualdialog", "DialogBox"]
25-
__version__ = 0.2
24+
__all__ = ["DialogBox"]
25+
__version__ = 0.3
2626
__author__ = "Arnouts Timéo"
2727

2828

2929
import curses
3030
import curses.textpad
3131
import random
32+
import textwrap
3233
import time
3334

3435
from typing import Tuple
3536

3637

37-
def init_visualdialog():
38-
...
39-
40-
4138
class DialogBox :
4239
"""This class provides methods and attributs to manage a dialog text box."""
4340

4441
# curses constants are supported .
4542
confirm_dialog_key = () # List of accepted key codes to pass a dialog.
46-
acceleration_dialog_key = None # TODO: To patch.
4743

4844
def __init__(self,
4945
pos_x: int, pos_y: int,
5046
box_length: int, box_width: int,
5147
title: str, title_colors_pair_nb: int,
5248
downtime_chars: Tuple[str] = ("!", ",", ".", ":", ";", "?"),
53-
downtime_chars_delay: float = 0.7,
49+
downtime_chars_delay: float = 0.6,
5450
end_dialog_indicator: str = "►"):
55-
5651
self.pos_x, self.pos_y = pos_x, pos_y
5752
self.box_length, self.box_width = box_length, box_width
5853

@@ -120,7 +115,7 @@ def _display_end_dialog_indicator(self, stdscr,
120115
def char_by_char(self, stdscr,
121116
text: str, colors_pair_nb: int,
122117
flash_screen: bool = False,
123-
delay: int = .065, random_delay: Tuple[int, int] = (0, 0)):
118+
delay: int = .05, random_delay: Tuple[int, int] = (0, 0)):
124119
"""Writes the given text character by character at position self.pos_x;self.pos_y.
125120
126121
The colors_pair_nb corresponds to the number of the curses color pair with which the text
@@ -130,7 +125,7 @@ def char_by_char(self, stdscr,
130125
dialog.
131126
132127
The delay parameter affects the waited time between the writing of each character in seconds
133-
(set by default on 0.7 seconde).
128+
(set by default on 0.05 seconde).
134129
135130
The random_delay parameter affects time between the writing of each character in seconds where
136131
waited time is a number generated in the given interval (as a tuple).
@@ -144,7 +139,6 @@ def char_by_char(self, stdscr,
144139
stdscr.addstr(
145140
self.text_pos_y, self.text_pos_x + x,
146141
char, curses.color_pair(colors_pair_nb))
147-
148142
stdscr.refresh()
149143

150144
if char in self.downtime_chars:
@@ -158,7 +152,7 @@ def word_by_word(self, stdscr,
158152
text: str, colors_pair_nb: int,
159153
cut_char: str = " ",
160154
flash_screen: bool = False,
161-
delay: int = .065, random_delay: Tuple[int, int] = (0, 0)):
155+
delay: int = .05, random_delay: Tuple[int, int] = (0, 0)):
162156
"""Writes the given text word by word at position at position self.pos_x;self.pos_y.
163157
164158
The colors_pair_nb corresponds to the number of the curses color pair with which the text
@@ -170,7 +164,7 @@ def word_by_word(self, stdscr,
170164
dialog.
171165
172166
The delay parameter affects the waited time between the writing of each word in seconds
173-
(set by default on 0.7 seconde).
167+
(set by default on 0.05 seconde).
174168
175169
The random_delay parameter affects time between the writing of each word in seconds where
176170
waited time is a number generated in the given interval (as a tuple).
@@ -187,18 +181,18 @@ def word_by_word(self, stdscr,
187181
word, curses.color_pair(colors_pair_nb))
188182

189183
stdscr.refresh()
190-
offsetting_x += len(word) + 1 # Compensates for the space between words.
184+
offsetting_x += len(word) + 1 # Compensates for the space between words.
191185
time.sleep(delay + random.uniform(*random_delay))
192186

193187
self._display_end_dialog_indicator(stdscr)
194188

195189

196190
def main(stdscr):
197191
text = (
198-
"Hello world",
199-
"How are you today ?",
200-
"Hi, bien ?",
201-
"Objection !"
192+
"Hello world, how are you today ?",
193+
"Press a key to skip this dialog.",
194+
"That is a basic example.",
195+
"See doc for more informations."
202196
)
203197

204198
curses.curs_set(0)
@@ -214,13 +208,15 @@ def main(stdscr):
214208
title="Dogm", title_colors_pair_nb=3,
215209
end_dialog_indicator="►")
216210

211+
textbox.confirm_dialog_key = (10, 32)
212+
217213
for reply in text:
218214
textbox.framing_box(stdscr)
219-
textbox.char_by_char(stdscr, reply, 2, flash_screen=True)
215+
textbox.char_by_char(stdscr, reply, 2)
220216

221217
textbox.getkey(stdscr)
222218
stdscr.clear()
223219

220+
224221
if __name__ == "__main__":
225222
curses.wrapper(main)
226-

0 commit comments

Comments
 (0)