Skip to content

Commit

Permalink
allow selection of multiple gurlz for micromanagement
Browse files Browse the repository at this point in the history
Signed-off-by: picobyte <pico0obyte@gmail.com>
  • Loading branch information
picobyte committed Nov 12, 2016
1 parent 1c02f31 commit a9e6aaa
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 61 deletions.
176 changes: 125 additions & 51 deletions game/library/screens/characters_listing.rpy
Expand Up @@ -6,19 +6,31 @@ init:
python:
def sorting_for_chars_list():
return hero.chars

def setSelection_for_chars_list(sel, lst, value="from_lst"):
for l in lst:
sel[l.name] = l if value == "from_lst" else None

def charlist_or_char(as_list=False):
if char_list_selection:
l = [x for x in char_list_selection.values() if x is not None]
if any(l):
return l;
return [char] if as_list else char

label chars_list:
scene bg gallery
# Check if we're the screen was loaded or not:
if not renpy.get_screen("chars_list"):
$ char_lists_filters = CharsSortingForGui(sorting_for_chars_list)
$ char_lists_filters.filter()
# We create the filters only from those that our chars actually have... not need for gibberish:
$ status_filters = list(set([c.status for c in hero.chars]))
$ location_filters = list(set([c.location for c in hero.chars]))
$ action_filters = list(set([c.action for c in hero.chars]))
# $ class_filters = set()
# for c in hero.chars:
python:
char_lists_filters = CharsSortingForGui(sorting_for_chars_list)
char_lists_filters.filter()
# We create the filters only from those that our chars actually have... not need for gibberish:
status_filters = list(set([c.status for c in hero.chars]))
location_filters = list(set([c.location for c in hero.chars]))
action_filters = list(set([c.action for c in hero.chars]))
selected_filters = set(['Status', 'Site', 'Action']) #, 'Class'
char_list_selection = { c.name: None for c in char_lists_filters.sorted }

show screen chars_list(source=char_lists_filters, page=chars_list_last_page_viewed, total_pages=1)
with dissolve
Expand Down Expand Up @@ -133,6 +145,13 @@ screen chars_list(source=None, page=0, total_pages=1):
else:
add ProportionalScale("content/gfx/interface/icons/free.png", 50, 50)
text "AP: [c.AP]" size 17 color ivory
button:
xysize (32, 32)
action ToggleDict(char_list_selection, c.name, true_value=c, false_value=None)
if char_list_selection[c.name] is None:
add (im.Scale('content/gfx/interface/icons/checkbox_unchecked.png', 25, 25)) align (0.5, 0.5)
else:
add(im.Scale('content/gfx/interface/icons/checkbox_checked.png', 25, 25)) align (0.5, 0.5)

vbox:
yalign 0.98
Expand Down Expand Up @@ -172,50 +191,105 @@ screen chars_list(source=None, page=0, total_pages=1):
left_padding 10
ypadding 10
pos (1005, 47)
xysize (270, 668)
viewport:
draggable True
mousewheel True
has vbox xsize 253
null height 5
label "Filters:" xalign 0.5 text_size 35 text_color white
button:
xysize (270, 418)
vbox:
spacing 5
viewport:
draggable True
mousewheel True
has vbox xsize 253
null height 5
label "Filters:" xalign 0.5 text_size 35 text_color white
hbox:
box_wrap True
button:
xalign 0.5
style_group "basic"
action ToggleSetMembership(selected_filters, 'Status')
text "Status" hover_color red
button:
xalign 0.5
style_group "basic"
action ToggleSetMembership(selected_filters, 'Site')
text "Site" hover_color brown
button:
xalign 0.5
style_group "basic"
action ToggleSetMembership(selected_filters, 'Action')
text "Action" hover_color blue

null height 20
hbox:
box_wrap True
style_group "basic"
if "Status" in selected_filters:
for f in status_filters:
button:
action ModFilterSet(source, "status_filters", f)
text "[f]" hover_color red
if "Site" in selected_filters:
for f in location_filters:
button:
action ModFilterSet(source, "location_filters", f)
text "[f]" hover_color brown
if "Action" in selected_filters:
for f in action_filters:
button:
action ModFilterSet(source, "action_filters", f)
text "[f]" hover_color blue
null height 50
button:
xalign 0.5
yalign 1.0
style_group "basic"
action source.clear
text "Reset"
# for block_name, filters in source.display_filters:
# label ("{=della_respira}{b}[block_name]:") xalign 0
# for item_1, item_2 in izip_longest(fillvalue=None, *[iter(filters)]*2):
# hbox:
# style_group "basic"
# for filter_item in [item_1, item_2]:
# if filter_item:
# $ filter_name, filter_group, filter_key = filter_item
# $ focus = source.get_focus(filter_group, filter_key)
# button:
# action [SelectedIf(focus), Function(source.add_filter, filter_group, filter_key)]
# text "[filter_name]" size 16
# Mass (de)selection Buttons ====================================>
frame:
background Frame(Transform("content/gfx/frame/p_frame5.png", alpha=0.9), 10, 10)
xalign 0.5
style_group "basic"
action source.clear
text "Reset"
null height 10
label "Status:" text_color white
hbox:
style_group "basic"
for f in status_filters:
textbutton "[f]":
action ModFilterSet(source, "status_filters", f)
label "Locations:" text_color white
hbox:
style_group "basic"
for f in location_filters:
textbutton "[f]":
action ModFilterSet(source, "location_filters", f)
label "Actions:" text_color white
hbox:
style_group "basic"
box_wrap True
for f in action_filters:
textbutton "[f]":
action ModFilterSet(source, "action_filters", f)
# for block_name, filters in source.display_filters:
# label ("{=della_respira}{b}[block_name]:") xalign 0
# for item_1, item_2 in izip_longest(fillvalue=None, *[iter(filters)]*2):
# hbox:
# style_group "basic"
# for filter_item in [item_1, item_2]:
# if filter_item:
# $ filter_name, filter_group, filter_key = filter_item
# $ focus = source.get_focus(filter_group, filter_key)
# button:
# action [SelectedIf(focus), Function(source.add_filter, filter_group, filter_key)]
# text "[filter_name]" size 16
yalign 0.5
# ypos 5
xysize (250, 50)
has hbox style_group "basic" align .5, .5 spacing 5
hbox:
spacing 5
button: # select all on current listing, deselects them if all are selected
xysize (66, 40)
action Function(setSelection_for_chars_list, char_list_selection, chars_list[0] + chars_list[1], value=None if all(char_list_selection[x.name] for x in chars_list[0] + chars_list[1]) else "from_lst")
text "These"
button: # every of currently filtered, also in next tabs
xysize (66, 40)
action If(not all(char_list_selection.values()), [Function(setSelection_for_chars_list, char_list_selection, source.sorted)])
text "All"
button: # deselect all
xysize (66, 40)
action If(any(char_list_selection.values()), [Function(setSelection_for_chars_list, char_list_selection, source.sorted, None)])
text "None"
# Mass action Buttons ====================================>
frame:
background Frame(Transform("content/gfx/frame/p_frame5.png", alpha=0.9), 10, 10)
xalign 0.5
yalign 0.5
xysize (250, 200)
has vbox style_group "basic" align .5, .5 spacing 5
vbox:
button:
xysize (150, 40)
action If(any(char_list_selection.values()), [Hide("chars_list"), With(dissolve), Jump('girl_training')])
text "Training"

use top_stripe(True)

25 changes: 15 additions & 10 deletions game/library/screens/training.rpy
Expand Up @@ -40,7 +40,7 @@ label girl_training:

# Ensure valid course if selected
if training_screen_course is not None:
if not training_screen_course.can_train(char, training_screen_trainer):
if not training_screen_course.can_train(charlist_or_char(), training_screen_trainer):
training_screen_course = None

while True:
Expand All @@ -56,15 +56,15 @@ label girl_training:
# Schooling
if training_screen_current.is_school:
# Slave and combat incompatibility
if char.status == "slave" and result[1].type == "Combat":
if any(c.status == "slave" for c in charlist_or_char(as_list=True)) and result[1].type == "Combat":
renpy.call_screen("message_screen", "Slaves cannot be trained as Warriors!")

else:
result[1].set_training(char, training_screen_current)
result[1].set_training(charlist_or_char(), training_screen_current)

# Normal training
else:
result[1].set_training(char, training_screen_current, training_screen_trainer)
result[1].set_training(charlist_or_char(), training_screen_current, training_screen_trainer)

break

Expand All @@ -73,7 +73,12 @@ label girl_training:
break

hide screen girl_training
jump char_profile
if char_list_selection == None:
jump char_profile
else:
$ char_list_selection = None
jump chars_list



screen girl_training:
Expand Down Expand Up @@ -185,7 +190,7 @@ screen girl_training_trainer:
box_wrap True
spacing 5
for course in sorted(training_screen_current.courses):
if course.can_train(char, hero, one_off_only=False):
if course.can_train(charlist_or_char(), hero, one_off_only=False):
frame:
background Frame("content/gfx/frame/p_frame2.png", 10, 10)
xysize (190, 190)
Expand Down Expand Up @@ -227,7 +232,7 @@ screen girl_training_trainer:
xsize 440
box_wrap True
spacing 7
for course in training_screen_course.get_options(char, training_screen_trainer, one_off_only=False):
for course in training_screen_course.get_options(charlist_or_char(), training_screen_trainer, one_off_only=False):
frame:
background Frame("content/gfx/frame/p_frame2.png", 10, 10)
xysize (210, 145)
Expand Down Expand Up @@ -318,7 +323,7 @@ screen girl_training_lesson(course, tt, show_image):

text (u"%s"%(course.gold))

text (u"%s"%(course.trainerStatus(char, training_screen_trainer)))
text (u"%s"%(course.trainerStatus(charlist_or_char(), training_screen_trainer)))


# Schools sub-screen
Expand Down Expand Up @@ -352,7 +357,7 @@ screen girl_training_schooling:
align (0, 0.7)
xpadding 10
ypadding 10
xysize (590, 610)
xysize (610, 610)
has vbox
null height 3
label ("[training_screen_current.name]") xalign 0.5 text_color ivory text_size 25
Expand All @@ -367,7 +372,7 @@ screen girl_training_schooling:
draggable False
mousewheel True
vbox:
xmaximum 590
xmaximum 610
spacing 10
text "Girls currently taking courses here:" color ivory
for entry in [girl for girl in hero.chars if girl.location == training_screen_current]:
Expand Down
23 changes: 23 additions & 0 deletions game/library/training/classes - training.rpy
Expand Up @@ -436,6 +436,8 @@ init -9 python:
"""
Whether this course is available for the girl.
"""
if isinstance(girl, list):
return any(self.can_train(g, hero, one_off_only) for g in girl)
# TODO: May not be upgraded to modern code properly:
# f self.jobs is not None and girl.occupation not in self.jobs: return False
if self.jobs is not None and girl.occupations.intersection(self.jobs): return False
Expand Down Expand Up @@ -482,6 +484,9 @@ init -9 python:
"""
The options that the girl can partake in for the class.
"""
if isinstance(girl, list):
return [i for i in self.options if any(i.can_train(g, hero) for g in girl) and (one_off_only is None or i.is_one_off_event == one_off_only)]

return [i for i in self.options if i.can_train(girl, hero) and (one_off_only is None or i.is_one_off_event == one_off_only)]


Expand Down Expand Up @@ -610,6 +615,8 @@ init -9 python:
"""
Whether the girl and hero/trainer meets the requirements for this method.
"""
if isinstance(girl, list):
return any(self.can_train(g, hero) for g in girl)
# If we are a one-off training event
if self.is_one_off_event:
# Check for AP as well
Expand Down Expand Up @@ -824,6 +831,12 @@ init -9 python:
"""
Sets a girl and hero combo for training.
"""
if isinstance(girl, list):
for g in girl:
if self.can_train(g, hero):
self.set_training(g, location, hero)
return

char_is_training(girl, self)
girl_training_with(girl, hero)
girl_training_left(girl, self.duration+1)
Expand Down Expand Up @@ -1029,6 +1042,12 @@ init -9 python:
"""
Sets a girl and hero combo for training.
"""
if isinstance(girl, list):
for g in girl:
if self.can_train(g, hero):
self.set_training(g, location, hero)
return

char_is_training(girl, self)
girl_training_with(girl, None)

Expand All @@ -1044,6 +1063,10 @@ init -9 python:
hero = The character to return the skill of.
is_girl = Whether the character passed is the girl being trained.
"""
if isinstance(hero, list):
l = [self.trainerKnowledge(h, is_girl, **kwargs) for h in hero]
return sum(l) / len(l) if len(l) else 0# return the average

# Are we the girl
if is_girl:
s = 0
Expand Down

0 comments on commit a9e6aaa

Please sign in to comment.