mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 20:47:17 +02:00
Removing mixins.py, as it's not in use. We now have a separate ConnectScreen model under the config app to store connect screens. ConfigValue's value fields are now CharFields instead of TextFields for the sake of efficiency and sanity. It is strongly recommended that you reset your config app and syncdb to load the fixture.
This commit is contained in:
parent
f1760e6521
commit
ffe9a563e0
5 changed files with 37 additions and 27 deletions
|
|
@ -1 +1 @@
|
|||
[{"pk": 9, "model": "config.commandalias", "fields": {"user_input": "@desc", "equiv_command": "@describe"}}, {"pk": 3, "model": "config.commandalias", "fields": {"user_input": "@dest", "equiv_command": "@destroy"}}, {"pk": 4, "model": "config.commandalias", "fields": {"user_input": "@nuke", "equiv_command": "@destroy"}}, {"pk": 6, "model": "config.commandalias", "fields": {"user_input": "@tel", "equiv_command": "@teleport"}}, {"pk": 2, "model": "config.commandalias", "fields": {"user_input": "ex", "equiv_command": "examine"}}, {"pk": 7, "model": "config.commandalias", "fields": {"user_input": "i", "equiv_command": "inventory"}}, {"pk": 8, "model": "config.commandalias", "fields": {"user_input": "inv", "equiv_command": "inventory"}}, {"pk": 1, "model": "config.commandalias", "fields": {"user_input": "l", "equiv_command": "look"}}, {"pk": 5, "model": "config.commandalias", "fields": {"user_input": "sa", "equiv_command": "say"}}, {"pk": 1, "model": "config.configvalue", "fields": {"conf_value": "Evennia Test Site", "conf_key": "site_name"}}, {"pk": 2, "model": "config.configvalue", "fields": {"conf_value": "2", "conf_key": "player_dbnum_start"}}, {"pk": 3, "model": "config.configvalue", "fields": {"conf_value": "Credits", "conf_key": "money_name_plural"}}, {"pk": 4, "model": "config.configvalue", "fields": {"conf_value": "Credit", "conf_key": "money_name_singular"}}, {"pk": 5, "model": "config.configvalue", "fields": {"conf_value": "0", "conf_key": "game_firstrun"}}, {"pk": 6, "model": "config.configvalue", "fields": {"conf_value": "1800", "conf_key": "idle_timeout"}}, {"pk": 7, "model": "config.configvalue", "fields": {"conf_value": "2", "conf_key": "default_home"}}, {"pk": 8, "model": "config.configvalue", "fields": {"conf_value": "\n%ch%cb==================================================================%cn\n Welcome to Evennia! Please type one of the following to begin:\n\n If you have an existing account, connect to it by typing:\n %chconnect <email> <password2>%cn\n If you need to create an account, type (without the <>'s):\n %chcreate \"<username>\" <email> <password>%cn\n%ch%cb==================================================================%cn\n", "conf_key": "connect_screen"}}]
|
||||
[{"pk": 1, "model": "config.connectscreen", "fields": {"is_active": 1, "name": "Default", "connect_screen_text": "%ch%cb==================================================================%cn\r\n Welcome to Evennia! Please type one of the following to begin:\r\n\r\n If you have an existing account, connect to it by typing:\r\n %chconnect <email> <password2>%cn\r\n If you need to create an account, type (without the <>'s):\r\n %chcreate \"<username>\" <email> <password>%cn\r\n%ch%cb==================================================================%cn\r\n"}}, {"pk": 9, "model": "config.commandalias", "fields": {"user_input": "@desc", "equiv_command": "@describe"}}, {"pk": 3, "model": "config.commandalias", "fields": {"user_input": "@dest", "equiv_command": "@destroy"}}, {"pk": 4, "model": "config.commandalias", "fields": {"user_input": "@nuke", "equiv_command": "@destroy"}}, {"pk": 6, "model": "config.commandalias", "fields": {"user_input": "@tel", "equiv_command": "@teleport"}}, {"pk": 2, "model": "config.commandalias", "fields": {"user_input": "ex", "equiv_command": "examine"}}, {"pk": 7, "model": "config.commandalias", "fields": {"user_input": "i", "equiv_command": "inventory"}}, {"pk": 8, "model": "config.commandalias", "fields": {"user_input": "inv", "equiv_command": "inventory"}}, {"pk": 1, "model": "config.commandalias", "fields": {"user_input": "l", "equiv_command": "look"}}, {"pk": 5, "model": "config.commandalias", "fields": {"user_input": "sa", "equiv_command": "say"}}, {"pk": 1, "model": "config.configvalue", "fields": {"conf_value": "Evennia Test Site", "conf_key": "site_name"}}, {"pk": 2, "model": "config.configvalue", "fields": {"conf_value": "2", "conf_key": "player_dbnum_start"}}, {"pk": 3, "model": "config.configvalue", "fields": {"conf_value": "Credits", "conf_key": "money_name_plural"}}, {"pk": 4, "model": "config.configvalue", "fields": {"conf_value": "Credit", "conf_key": "money_name_singular"}}, {"pk": 5, "model": "config.configvalue", "fields": {"conf_value": "0", "conf_key": "game_firstrun"}}, {"pk": 6, "model": "config.configvalue", "fields": {"conf_value": "1800", "conf_key": "idle_timeout"}}, {"pk": 7, "model": "config.configvalue", "fields": {"conf_value": "2", "conf_key": "default_home"}}]
|
||||
|
|
|
|||
|
|
@ -24,3 +24,31 @@ class ConfigValue(models.Model):
|
|||
|
||||
class Admin:
|
||||
list_display = ('conf_key', 'conf_value',)
|
||||
|
||||
class ConnectScreenManager(models.Manager):
|
||||
def get_random_connect_screen(self):
|
||||
"""
|
||||
Returns a random active connect screen.
|
||||
"""
|
||||
try:
|
||||
return self.filter(is_active=True).order_by('?')[0]
|
||||
except IndexError:
|
||||
new_screen = ConnectScreen(name='Default',
|
||||
connect_screen_text='This is a placeholder connect screen. Remind your admin to edit it through the Admin interface.')
|
||||
new_screen.save()
|
||||
return new_screen
|
||||
|
||||
class ConnectScreen(models.Model):
|
||||
"""
|
||||
Stores connect screens. The admins may have only one or multiple, which
|
||||
will cycle randomly.
|
||||
"""
|
||||
name = models.CharField(max_length=255, help_text="An optional name for this screen (for organizational purposes).", blank=True)
|
||||
connect_screen_text = models.TextField(help_text="The text for the connect screen. Color codes and substitutions are evaluated.")
|
||||
is_active = models.BooleanField(default=1, help_text="Only active connect screens are placed in the rotation")
|
||||
|
||||
# Custom manager
|
||||
objects = ConnectScreenManager()
|
||||
|
||||
class Admin:
|
||||
list_display = ('id', 'name', 'is_active')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
from traceback import format_exc
|
||||
|
||||
from apps.config.models import ConfigValue
|
||||
from apps.config.models import ConfigValue, ConnectScreen
|
||||
import functions_general
|
||||
"""
|
||||
Handle the setting/retrieving of server config directives.
|
||||
|
|
@ -31,3 +31,4 @@ def set_configvalue(configname, newvalue):
|
|||
conf = ConfigValue.objects.get(conf_key=configname)
|
||||
conf.conf_value = newvalue
|
||||
conf.save()
|
||||
|
||||
|
|
|
|||
22
mixins.py
22
mixins.py
|
|
@ -1,22 +0,0 @@
|
|||
"""
|
||||
The ReloadMixin class is meant as an example, but should work
|
||||
for basic purposes as a mixin inheritance.
|
||||
"""
|
||||
class ReloadMixin():
|
||||
"""
|
||||
This class is a generic reload mixin providing the two
|
||||
methods required to cache and reload an object.
|
||||
"""
|
||||
def cache(self, reloader, do_save=True):
|
||||
if do_save:
|
||||
if self.save and callable(self.save):
|
||||
self.save()
|
||||
else:
|
||||
raise ValueError("This object does not have a save function, you must pass do_save=False for this object type.")
|
||||
|
||||
reloader.cache_object(self)
|
||||
|
||||
def reload(self, cache):
|
||||
for key, value in cache.iteritems():
|
||||
if self.__dict__[key] != value:
|
||||
self.__dict__[key] = value
|
||||
|
|
@ -4,9 +4,11 @@ import cPickle as pickle
|
|||
|
||||
from twisted.conch.telnet import StatefulTelnetProtocol
|
||||
|
||||
import cmdhandler
|
||||
from apps.objects.models import Object
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from apps.objects.models import Object
|
||||
from apps.config.models import ConnectScreen
|
||||
import cmdhandler
|
||||
import functions_db
|
||||
import functions_general
|
||||
import session_mgr
|
||||
|
|
@ -121,7 +123,8 @@ class SessionProtocol(StatefulTelnetProtocol):
|
|||
"""
|
||||
Show the banner screen. Grab from the 'connect_screen' config directive.
|
||||
"""
|
||||
buffer = ansi.parse_ansi(gameconf.get_configvalue('connect_screen'))
|
||||
screen = ConnectScreen.objects.get_random_connect_screen()
|
||||
buffer = ansi.parse_ansi(screen.connect_screen_text)
|
||||
self.msg(buffer)
|
||||
|
||||
def is_loggedin(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue