activate prompt

This commit is contained in:
Frank DeMarco 2014-01-23 01:20:38 +09:00
parent daeb3f1e66
commit dac6f94e4b
2 changed files with 57 additions and 2 deletions

View File

@ -138,6 +138,11 @@ class Configuration(RawConfigParser):
set_option(section, "label-size", "16", False)
set_option(section, "label-precision", "2", False)
set_option(section, "axis-label-count", "8", False)
set_option(section, "prompt-size", "200, 80", False)
set_option(section, "prompt-border-color", "255, 0, 0", False)
set_option(section, "prompt-border-width", "3", False)
set_option(section, "prompt-character-limit", "6", False)
set_option(section, "prompt-text-size", "52", False)
def add_section(self, name):
if name not in self.order:
@ -385,9 +390,14 @@ class TypeDeclarations(dict):
"event": {"int": "command-id-offset"},
"interpolator-gui": {"int": ["margin", "marker-size", "label-size",
"axis-label-count", "label-precision"],
"axis-label-count", "label-precision",
"prompt-border-width",
"prompt-character-limit",
"prompt-text-size"],
"int-list": ["marker-color", "curve-color"]},
"int-list": ["marker-color", "curve-color",
"prompt-size",
"prompt-border-color"]},
}

View File

@ -185,6 +185,7 @@ class GUI(GameChild):
self.delegate = self.get_delegate()
self.load_configuration()
self.font = Font(None, self.label_size)
self.prompt = Prompt(self)
self.set_background()
self.set_plot_rect()
self.set_marker_frame()
@ -339,6 +340,8 @@ class GUI(GameChild):
if nodeset_rect.collidepoint(pos):
self.set_nodeset_index(1)
redraw = True
elif self.axis_labels[0][0][1].collidepoint(pos):
self.prompt.activate(self.get_nodeset()[0].x, self.draw)
else:
bi = self.collide_buttons(pos)
if bi is not None:
@ -478,3 +481,45 @@ class Button(Sprite):
def set_frame(self, text):
self.add_frame(self.parent.font.render(text, True, (0, 0, 0),
(255, 255, 255)))
class Prompt(Sprite):
def __init__(self, parent):
Sprite.__init__(self, parent)
self.load_configuration()
self.font = Font(None, self.text_size)
self.set_frame()
self.location.center = self.display_surface.get_rect().center
self.deactivate()
def deactivate(self):
self.active = False
def load_configuration(self):
config = self.get_configuration("interpolator-gui")
self.size = config["prompt-size"]
self.border_color = config["prompt-border-color"]
self.border_width = config["prompt-border-width"]
self.character_limit = config["prompt-character-limit"]
self.text_size = config["prompt-text-size"]
def set_frame(self):
surface = Surface(self.size)
self.add_frame(surface)
surface.fill(self.border_color)
width = self.border_width * 2
surface.fill((0, 0, 0), self.location.inflate(-width, -width))
def activate(self, text, callback):
self.active = True
self.text = str(text)
self.callback = callback
self.update()
self.draw_text()
def draw_text(self):
surface = self.font.render(self.text, True, (255, 255, 255), (0, 0, 0))
rect = surface.get_rect()
rect.center = self.location.center
self.display_surface.blit(surface, rect)