-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/LogicalDash/LiSE
- Loading branch information
Showing
39 changed files
with
592 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# This file is part of LiSE, a framework for life simulation games. | ||
# Copyright (C) Zachary Spector, [email protected] | ||
"""Object to configure, start, and stop ELiDE.""" | ||
|
||
import json | ||
|
||
from kivy.logger import Logger | ||
|
@@ -29,8 +31,6 @@ | |
import ELiDE.charsview | ||
from .util import trigger | ||
|
||
"""Object to configure, start, and stop ELiDE.""" | ||
|
||
resource_add_path(ELiDE.__path__[0] + "/assets") | ||
resource_add_path(ELiDE.__path__[0] + "/assets/rltiles") | ||
|
||
|
@@ -232,11 +232,10 @@ def tog(*args): | |
) | ||
|
||
self.funcs = ELiDE.funcsed.FuncsEdScreen( | ||
table='trigger', | ||
store=self.engine.trigger, | ||
app=self, | ||
name='funcs', | ||
toggle=toggler('funcs') | ||
) | ||
self.funcs.bind(data=self.rules.rulesview._trigger_update_builders) | ||
|
||
self.select_character( | ||
self.engine.character[ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
# This file is part of LiSE, a framework for life simulation games. | ||
# Copyright (c) Zachary Spector, [email protected] | ||
"""The big widget that shows the graph of the selected Character.""" | ||
from functools import partial | ||
from kivy.properties import ( | ||
AliasProperty, | ||
BooleanProperty, | ||
StringProperty, | ||
ReferenceListProperty, | ||
DictProperty, | ||
ObjectProperty, | ||
|
@@ -23,10 +23,20 @@ | |
|
||
|
||
class KvLayoutBack(FloatLayout): | ||
"""What to show behind the graph. | ||
By default, shows a static image. | ||
""" | ||
character = ObjectProperty() | ||
|
||
|
||
class KvLayoutFront(FloatLayout): | ||
"""What to show in front of the graph. | ||
By default, shows nothing. | ||
""" | ||
pass | ||
|
||
|
||
|
@@ -144,6 +154,11 @@ def make_spot(self, place): | |
place=place | ||
) | ||
self.spot[place["name"]] = r | ||
if '_x' in place and '_y' in place: | ||
r.pos = ( | ||
self.width * place['_x'], | ||
self.height * place['_y'] | ||
) | ||
return r | ||
|
||
def make_arrow(self, portal): | ||
|
@@ -356,11 +371,31 @@ def add_new_spots(self, *args): | |
) | ||
) | ||
spots_added = [] | ||
nodes_patch = {} | ||
for place_name in self.app.character.place: | ||
if place_name not in self.spot: | ||
spot = self.make_spot(self.app.character.place[place_name]) | ||
place = self.app.character.place[place_name] | ||
spot = self.make_spot(place) | ||
patch = {} | ||
if '_image_paths' in place: | ||
zeroes = [0] * len(place['_image_paths']) | ||
else: | ||
patch['_image_paths'] = spot.default_image_paths | ||
zeroes = [0] | ||
if '_offxs' not in place: | ||
patch['_offxs'] = zeroes | ||
if '_offys' not in place: | ||
patch['_offys'] = zeroes | ||
if '_stackhs' not in place: | ||
patch['_stackhs'] = zeroes | ||
nodes_patch[place_name] = patch | ||
self.spotlayout.add_widget(spot) | ||
spots_added.append(spot) | ||
self.app.engine.handle( | ||
'update_nodes', (self.app.character.name, nodes_patch) | ||
) | ||
for spot in spots_added: | ||
spot.finalize() | ||
self.new_spots = spots_added | ||
|
||
def add_arrow(self, orign, destn, *args): | ||
|
@@ -421,9 +456,26 @@ def add_new_pawns(self, *args): | |
self.app.character.name | ||
) | ||
) | ||
nodes_patch = {} | ||
pawns_added = [] | ||
for thing_name in self.app.character.thing: | ||
if thing_name not in self.pawn: | ||
pwn = self.make_pawn(self.app.character.thing[thing_name]) | ||
thing = self.app.character.thing[thing_name] | ||
pwn = self.make_pawn(thing) | ||
pawns_added.append(pwn) | ||
patch = {} | ||
if '_image_paths' in thing: | ||
zeroes = [0] * len(thing['_image_paths']) | ||
else: | ||
patch['_image_paths'] = Pawn.default_image_paths | ||
zeroes = [0] * len(Pawn.default_image_paths) | ||
if '_offxs' not in thing: | ||
patch['_offxs'] = zeroes | ||
if '_offys' not in thing: | ||
patch['_offys'] = zeroes | ||
if '_stackhs' not in thing: | ||
patch['_stackhs'] = zeroes | ||
nodes_patch[thing_name] = patch | ||
try: | ||
whereat = self.arrow[ | ||
pwn.thing['location'] | ||
|
@@ -434,6 +486,11 @@ def add_new_pawns(self, *args): | |
whereat = self.spot[pwn.thing['location']] | ||
whereat.add_widget(pwn) | ||
self.pawn[thing_name] = pwn | ||
self.app.engine.handle( | ||
'update_nodes', (self.app.character.name, nodes_patch) | ||
) | ||
for pwn in pawns_added: | ||
pwn.finalize() | ||
|
||
@trigger | ||
def trigger_update(self, *args): | ||
|
@@ -464,6 +521,10 @@ def update_from_diff(self, chardiff, *args): | |
for (place, extant) in chardiff['places'].items(): | ||
if extant and place not in self.spot: | ||
self.add_spot(place) | ||
spot = self.spot[place] | ||
if '_x' not in spot.place or '_y' not in spot.place: | ||
self.new_spots.append(spot) | ||
self.spots_unposd.append(spot) | ||
elif not extant and place in self.spot: | ||
self.rm_spot(place) | ||
for (thing, extant) in chardiff['things'].items(): | ||
|
@@ -523,23 +584,27 @@ def nx_layout(self, *args): | |
go, and move them there. | ||
""" | ||
for spot in self.new_spots: | ||
if not (spot.name and spot.remote): | ||
Clock.schedule_once(self.nx_layout, 0) | ||
return | ||
spots_only = self.app.character.facade() | ||
for thing in list(spots_only.thing.keys()): | ||
del spots_only.thing[thing] | ||
l = self.grid_layout(spots_only) | ||
|
||
def position_spot(spot, x, y, *args): | ||
if not (spot.name and spot.remote): | ||
Clock.schedule_once(partial(position_spot, spot, x, y), 0) | ||
return | ||
spot.remote['_x'] = x | ||
spot.remote['_y'] = y | ||
node_upd = {} | ||
|
||
for spot in self.new_spots: | ||
(x, y) = l[spot.name] | ||
node_upd[spot.remote.name] = {'_x': x, '_y': y} | ||
spot.pos = ( | ||
int(x * self.width), | ||
int(y * self.height) | ||
) | ||
for spot in self.new_spots: | ||
position_spot(spot, *l[spot.name]) | ||
self.app.engine.handle( | ||
'update_nodes', (self.app.character.name, node_upd) | ||
) | ||
self.new_spots = self.spots_unposd = [] | ||
|
||
def arrows(self): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
# This file is part of LiSE, a framework for life simulation games. | ||
# Copyright (C) Zachary Spector, [email protected] | ||
"""Widget that looks like a trading card, and a layout within which it | ||
can be dragged and dropped to some particular position within stacks | ||
of other cards. | ||
""" | ||
|
||
|
||
from kivy.clock import Clock | ||
from kivy.lang import Builder | ||
from kivy.logger import Logger | ||
|
@@ -24,13 +31,6 @@ | |
from kivy.uix.widget import Widget | ||
|
||
|
||
"""Widget that looks like a trading card, and a layout within which it | ||
can be dragged and dropped to some particular position within stacks | ||
of other cards. | ||
""" | ||
|
||
|
||
dbg = Logger.debug | ||
|
||
|
||
|
Oops, something went wrong.