-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdraw.py
More file actions
38 lines (27 loc) · 1.04 KB
/
draw.py
File metadata and controls
38 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from textwrap import TextWrapper
from mods_base import html_to_plain_text
from unrealsdk import logging
wrapper = TextWrapper(width=100, expand_tabs=True, tabsize=2)
def draw(msg: str, indent: int = 0) -> None:
"""
Draws a message to console for the interactive mod menu.
The empty string will draw an empty line. Any other message may have word wrapping applied.
Args:
msg: The message to write.
indent: How much to indent the message.
"""
prefix = "Mod Menu | " + (" " * indent)
if not msg:
logging.info("Mod Menu |")
return
for line in wrapper.fill(html_to_plain_text(msg)).splitlines():
logging.info(prefix, line)
def draw_description(description: str, indent: int = 0) -> None:
"""
Draws a message coming from a mod/option description - honoring existing newlines.
Args:
description: The description to write.
indent: How much to indent the message.
"""
for line in html_to_plain_text(description).splitlines():
draw(line, indent)