lib/rubyfox/server/data/config/admin/gmc/gmc.py in rubyfox-server-2.13.7.3 vs lib/rubyfox/server/data/config/admin/gmc/gmc.py in rubyfox-server-2.16.0.0

- old
+ new

@@ -1,27 +1,51 @@ +# +# _____ _____ ____ _____ _____ ____ _____ +# | __| | \ | | | \| __| +# | | | | | | | | | | | | | | | __| +# |_____|_____|____/ |_|_|_|_____|____/|_____| +# _____ _____ _____ _____ _____ __ _____ +# | | | | | __| | | | __| +# | --| | | | | |__ | | | |__| __| +# |_____|_____|_|___|_____|_____|_____|_____| +# +# SmartFoxServer2X Admin Console Scripts +# +# (c) 2012-2016 gotoAndPlay() +# @author Marco Lapi +# +# Version 2.x +# + +# Python Imports import types import sys + +# +# This global variable allows to lock the Console so that it can't be misused +# __CONSOLE_LOCK = False +# Java Imports import java from com.smartfoxserver.v2.entities.data import * -__scripts = [ +__scripts = [ {'name':'version()', 'doc':'Shows the Console extension version'}, {'name':'reloadScripts()', 'doc':'Reload the dynamic server scripts'}, {'name':'execute()', 'doc':'Launches the last loaded script again'}, {'name':'files(path)', 'doc':'Shows the files at the specified path'}, {'name':'controller(id)', 'doc':'Obtain one of the controllers from its id. 0=System, 1=Extension, 2=Smasher'}, {'name':'zones()', 'doc':'List of active zones'} ] - -__shortcuts = [ + +__shortcuts = [ {'name':'ESC', 'doc':'Clears current command'}, {'name':'UP ARROW', 'doc':'Previous command in history'}, {'name':'DOWN ARROW', 'doc':'Next command in history'}, - {'name':'CTRL + SPACE', 'doc':'Show command history'}, + {'name':'CTRL + SPACE', 'doc':'Show code hinting'}, {'name':'CTRL + BACKSPACE', 'doc':'Clear console text'} ] grid = None @@ -35,59 +59,74 @@ """Shows a list of useful global objects""" text = "" for (key, value) in _2XGlobals_.items(): if value != None: cl = str(value.getClass()) - text += "<font color='#FFCC00'>" + key + "</font>\t\t\t" + cl.split(".")[-1] + "\n" + text += "<span class='text-highlight'>" + key + "</span>\t\t\t" + cl.split(".")[-1] + "\n" - text += "\n<font color='#FFCC00'>extras()</font>\t\tFor more custom function calls" - text += "\n<font color='#FFCC00'>shortcuts()</font>\tFor keyboard shortcuts details\n" + text += "\n<span class='text-highlight'>extras()</span>\t\tFor more custom function calls" + text += "\n<span class='text-highlight'>shortcuts()</span>\tFor keyboard shortcuts details\n" return text def shortcuts(): """Shows list of useful keyboard shortcuts""" return __showList__(__shortcuts) - + def extras(): """Shows list of useful methods""" return __showList__(__scripts) - - + + + + +# -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == +# Useful methods +# (can be added dynamically) +# -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == + def version(): return __parent__.VER def controller(id): from java.lang import Byte bb = Byte(id) return eng.controllerManager.getControllerById(bb) def reloadScripts(): __parent__.init() - return "<font color='#ffCC00'>[[ Reload success! ]]</font>" + return "<span class='text-highlight'>[[ Reload success! ]]</span>" def files(path='.'): import os return os.listdir(path) def zones(): return zm.getZoneList() + +# -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == +# Private methods +# -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == -- == + def __showList__(someList): text = "" - + for item in someList: - text += "<font color='#FFCC00'>" + item['name'] + "</font>" + text += "<span class='text-highlight'>" + item['name'] + "</span>" text += ":" + __getSpacer__(item['name']) + item['doc'] + "\n" return text def __hints__(obj, target): if obj == None: return + # + # Generate all hints excluding private members + # hints = None try: hints = [item for item in dir(obj)] except: @@ -100,19 +139,17 @@ # Send hint list from com.smartfoxserver.v2.entities.data import SFSObject sfso = SFSObject() sfso.putUtfStringArray('h', hints) - + return sfso def __getSpacer__(inputStr): DEFAULT_SPACES = 25 spacer = " " - + nSpaces = DEFAULT_SPACES - len(inputStr) if nSpaces > 0: spacer = " " * nSpaces - - return spacer - \ No newline at end of file + return spacer