Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Custom bg names #120

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config_sample/areas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
## evidence_mod: FFA
## locking_allowed: false
## iniswap_allowed: true
## background: gs4
## bglock: false
## custom_bg_allowed: true
## showname_changes_allowed: true
## shouts_allowed: true
## jukebox: false
Expand Down
17 changes: 12 additions & 5 deletions server/area_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ def __init__(self,
area_id,
server,
name,
background,
bg_lock,
background='gs4',
bg_lock=False,
custom_bg=True,
evidence_mod='FFA',
locking_allowed=False,
iniswap_allowed=True,
Expand All @@ -54,6 +55,7 @@ def __init__(self,
self.name = name
self.background = background
self.bg_lock = bg_lock
self.custom_bg = custom_bg
self.server = server
self.music_looper = None
self.next_message_time = 0
Expand Down Expand Up @@ -410,8 +412,7 @@ def change_background(self, bg: str):
Raises:
AreaError: if `bg` is not in background list
"""

if bg.lower() not in (name.lower()
if self.custom_bg == False or bg.lower() not in (name.lower()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will always say "invalid background name" if custom backgrounds is set to false.

Suggested change
if self.custom_bg == False or bg.lower() not in (name.lower()
if not self.custom_bg and bg.lower() not in (name.lower()

for name in self.server.backgrounds):
raise AreaError('Invalid background name.')
self.background = bg
Expand Down Expand Up @@ -738,6 +739,12 @@ def load_areas(self):
item['locking_allowed'] = False
if 'iniswap_allowed' not in item:
item['iniswap_allowed'] = True
if 'background' not in item:
item['background'] = 'gs4'
if 'bglock' not in item:
item['bglock'] = False
if 'custom_bg_allowed' not in item:
item['custom_bg_allowed'] = True
if 'showname_changes_allowed' not in item:
item['showname_changes_allowed'] = True
if 'shouts_allowed' not in item:
Expand All @@ -751,7 +758,7 @@ def load_areas(self):
item['area'])
self.areas.append(
self.Area(self.cur_id, self.server, item['area'],
item['background'], item['bglock'],
item['background'], item['bglock'], item['custom_bg_allowed'],
item['evidence_mod'], item['locking_allowed'],
item['iniswap_allowed'],
item['showname_changes_allowed'],
Comment on lines +761 to 764
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually now that this was changed, I think you can actually get away with doing

self.Area(self.cur_id, self.server, **item)

and then the default parameters set in item just above become redundant.

Expand Down