changeset 98:95b5281e8d34 alpha

Traipse Alpha 'OpenRPG' {090925-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary: 00: Update forwards to the 090909-02 Server code that now works. New default Lobby Map, designed for Traipse. Feel free to change it. Updates to Server GUI: * Admin can Ban from Backend. * Prework to modify Ban List in back end. * Server GUI finds your Lobby Name * New users default as Lurker unless a Role is set New Addition to Chat Die Roll commands. Math Ordering. Ex. [(X+Y)dZ]. Currently does pairs only, no nesting either. Cleaner TraipseSuiteAttention portability and clean up in Main (Beta!) 01: Die Roll Commands addition removed in favor of Core code {090925-00}: Updates to Server GUI: *Admin can Modify Ban List and Un Ban users. New About Dialog. A more uniform About Dialog.
author sirebral
date Fri, 25 Sep 2009 06:16:37 -0500
parents bb22f0f1a7ec
children a647e0e8f520
files orpg/main.py orpg/networking/mplay_server.py orpg/networking/mplay_server_gui.py orpg/orpg_version.py
diffstat 4 files changed, 165 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/orpg/main.py	Thu Sep 24 21:21:49 2009 -0500
+++ b/orpg/main.py	Fri Sep 25 06:16:37 2009 -0500
@@ -579,37 +579,8 @@
     #Help Menu #Needs a custom Dialog because it is ugly on Windows
     @debugging
     def OnMB_HelpAbout(self):
-
-        description = "OpenRPG is a Virtual Game Table that allows users to connect via a network and play table\n"
-        description += "top games with friends.  'Traipse' is an OpenRPG distro that is easy to setup and provides superb \n"
-        description += "functionality.  OpenRPG is originally designed by Chris Davis. \n"
-
-        license = "OpenRPG is free software; you can redistribute it and/or modify it "
-        license += "under the terms of the GNU General Public License as published by the Free Software Foundation; \n"
-        license += "either version 2 of the License, or (at your option) any later version.\n\n"
-        license += "OpenRPG and Traipse 'OpenRPG' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; \n"
-        license += "without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  \n"
-        license += "See the GNU General Public License for more details. You should have received a copy of \n"
-        license += "the GNU General Public License along with Traipse 'OpenRPG'; if not, write to \n"
-        license += "the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n\n"
-        license += "'Traipse' and the 'Traipse' Logo are trademarks of Mad Mathematics Laboratories."
-
-        info = wx.AboutDialogInfo()
-        info.SetIcon(wx.Icon(dir_struct["icon"]+'splash.gif', wx.BITMAP_TYPE_GIF))
-        info.SetName('Traipse')
-        info.SetVersion('OpenRPG ' + VERSION)
-        info.SetDescription(description)
-        info.SetCopyright('(C) Copyright 2009 Mad Math Labs')
-        info.SetWebSite('http://www.openrpg.com')
-        info.SetLicence(license)
-        orpg_devs = ['Thomas Baleno', 'Andrew Bennett', 'Lex Berezhny', 'Ted Berg',
-		'Bernhard Bergbauer', 'Chris Blocher', 'David Byron', 'Ben Collins-Sussman', 'Robin Cook', 'Greg Copeland',
-		'Chris Davis', 'Michael Edwards', 'Andrew Ettinger', 'Todd Faris', 'Dj Gilcrease',
-        'Christopher Hickman', 'Paul Hosking', 'Brian Manning', 'Scott Mackay', 'Jesse McConnell', 
-		'Brian Osman', 'Rome Reginelli', 'Christopher Rouse', 'Dave Sanders', 'Tyler Starke', 'Mark Tarrabain']
-        for dev in orpg_devs:
-            info.AddDeveloper(dev)
-        wx.AboutBox(info)
+        if self.AboutORPG.IsShown() == True: self.AboutORPG.Hide()
+        else: self.AboutORPG.Show()
 
     @debugging
     def OnMB_HelpOnlineUserGuide(self):
@@ -651,6 +622,9 @@
         self.windowsmenu = wx.Menu()
         self.mainwindows = {}
 
+        # About Window
+        self.AboutORPG = AboutORPG(self)
+
         #Plugins Window
         self.pluginsFrame = pluginUI.PluginFrame(self)
         component.add("plugins", self.get_activeplugins())
@@ -664,7 +638,7 @@
         self.SetDimensions(posx, posy, w, h)
         logger.debug("Dimensions Set")
 
-        #Update Manager
+        # Update Manager
         self.manifest = manifest.ManifestChanges()
         self.updateMana = upmana.updatemana.updaterFrame(self, 
             "OpenRPG Update Manager Beta 0.8", component, self.manifest, True)
@@ -677,8 +651,7 @@
         self.SetDimensions(posx, posy, w, h)
         logger.debug("Dimensions Set")
 
-        #Update Manager
-        self.manifest = manifest.ManifestChanges()
+        # Debug Console
         self.debugger = orpg.tools.orpg_log.DebugConsole(self)
         logger.debug("Menu Created")
         h = int(xml_dom.getAttribute("height"))
@@ -1172,6 +1145,58 @@
         except Exception:
             pass
 
+########################################
+## About Dialog class
+########################################
+class AboutORPG(wx.Frame):
+    def __init__(self, parent):
+        super(AboutORPG, self).__init__(parent, -1, "About 'Traipse' OpenRPG")
+        icon = None
+        icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
+        self.SetIcon( icon )
+        sizer = wx.GridBagSizer(hgap=1, vgap=1)
+        height = 425; width = 350
+        self.About = wx.TextCtrl(self, -1, size=wx.DefaultSize, style=wx.TE_MULTILINE | wx.TE_READONLY)
+        img = wx.Image(dir_struct['icon']+'splash.gif', wx.BITMAP_TYPE_ANY).ConvertToBitmap()
+        image = wx.StaticBitmap(self, -1, img, size=wx.DefaultSize)
+        sizer.Add(image, (0,0), flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALL|wx.ADJUST_MINSIZE)
+        sizer.Add(self.About, (1,0), flag=wx.EXPAND)
+        self.SetSizer(sizer)
+        self.SetAutoLayout(True)
+        self.SetSize((width, height))
+        sizer.AddGrowableCol(0)
+        sizer.AddGrowableCol(1)
+        sizer.AddGrowableRow(1)
+        self.Bind(wx.EVT_CLOSE, self.Min) 
+        self.Min(None)
+
+        description = "OpenRPG is a Virtual Game Table that allows users to connect via a network and play table "
+        description += "top games with friends.  'Traipse' is an OpenRPG distro that is easy to setup and provides superb "
+        description += "functionality.  OpenRPG is originally designed by Chris Davis."
+
+        license = "OpenRPG is free software; you can redistribute it and/or modify it "
+        license += "under the terms of the GNU General Public License as published by the Free Software Foundation; "
+        license += "either version 2 of the License, or (at your option) any later version.\n\n"
+        license += "OpenRPG and Traipse 'OpenRPG' is distributed in the hope that it will be useful, but WITHOUT ANY "
+        license += "WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
+        license += "See the GNU General Public License for more details. You should have received a copy of "
+        license += "the GNU General Public License along with Traipse 'OpenRPG'; if not, write to "
+        license += "the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \n\n"
+        license += "'Traipse' and the 'Traipse' Logo are trademarks of Mad Mathematics Laboratories."
+
+        self.About.AppendText(description+'\n\n')
+        self.About.AppendText(license+'\n\n')
+        self.About.AppendText('OpenRPG Developers:\n')
+        orpg_devs = ['Thomas Baleno', 'Andrew Bennett', 'Lex Berezhny', 'Ted Berg',
+		'Bernhard Bergbauer', 'Chris Blocher', 'David Byron', 'Ben Collins-Sussman', 'Robin Cook', 'Greg Copeland',
+		'Chris Davis', 'Michael Edwards', 'Andrew Ettinger', 'Todd Faris', 'Dj Gilcrease',
+        'Christopher Hickman', 'Paul Hosking', 'Brian Manning', 'Scott Mackay', 'Jesse McConnell', 
+		'Brian Osman', 'Rome Reginelli', 'Christopher Rouse', 'Dave Sanders', 'Tyler Starke', 'Mark Tarrabain']
+        for dev in orpg_devs:
+            self.About.AppendText(dev+'\n')
+
+    def Min(self, evt):
+        self.Hide()
 
 ########################################
 ## Application class
--- a/orpg/networking/mplay_server.py	Thu Sep 24 21:21:49 2009 -0500
+++ b/orpg/networking/mplay_server.py	Fri Sep 25 06:16:37 2009 -0500
@@ -2080,8 +2080,22 @@
             traceback.print_exc()
             self.log_msg('Exception in admin_kick() ' + str(e))
 
+    ### Alpha ### Addition added to assist in Un Banning users.
+    def admin_build_banlist(self):
+        validate.config_file("ban_list.xml", "default_ban_list.xml" ) 
+        configDom = minidom.parse(dir_struct["user"] + 'ban_list.xml')
+        self.ban_list = {}
+        for element in configDom.getElementsByTagName('banned'):
+            player = element.getAttribute('name').replace("&", "&amp;").replace("<", "&lt;").replace('"', "&quot;").replace(">", "&gt;")
+            ip = element.getAttribute('ip')
+            self.ban_list[ip] = {}
+            self.ban_list[ip]['ip'] = ip
+            self.ban_list[ip]['name'] = element.getAttribute('name')
+    ################
+
     def admin_banip(self, ip, name="", silent = 0):
         "Ban a player from a server from the console"
+        self.adming_buile_banlist() ### Alpha ###
         try:
             self.ban_list[ip] = {}
             self.ban_list[ip]['ip'] = ip
@@ -2125,6 +2139,7 @@
             self.log_msg('Exception in admin_ban() ' + str(e))
 
     def admin_unban(self, ip):
+        self.admin_build_banlist()
         try:
             if self.ban_list.has_key(ip): del self.ban_list[ip]
             self.saveBanList()
@@ -2571,3 +2586,5 @@
         except Exception, e: self.log_msg(str(e))
         self.p_lock.release()
         return pl
+
+server = mplay_server()
--- a/orpg/networking/mplay_server_gui.py	Thu Sep 24 21:21:49 2009 -0500
+++ b/orpg/networking/mplay_server_gui.py	Fri Sep 25 06:16:37 2009 -0500
@@ -20,8 +20,9 @@
 import webbrowser
 from threading import Thread
 from meta_server_lib import post_server_data, remove_server
-from mplay_server import mplay_server
+from mplay_server import mplay_server, server
 from xml.dom import minidom
+from orpg.orpgCore import component
 
 # Constants ######################################
 SERVER_RUNNING = 1
@@ -42,6 +43,8 @@
 MENU_PLAYER_BOOT = wx.NewId()
 ### Alpha ###
 MENU_ADMIN_BAN = wx.NewId()
+MENU_BAN_LIST = wx.NewId()
+MENU_ADMIN_UNBAN = wx.NewId()
 #############
 MENU_PLAYER_CREATE_ROOM = wx.NewId()
 MENU_PLAYER_SEND_MESSAGE = wx.NewId()
@@ -99,17 +102,6 @@
         OPENRPG_PORT = 6774 if port == '' else int(port) #Pretty ugly, but I couldn't find the tag any other way.
         self.owner = owner
 
-        ### Early Alpha ### This is prep for the Modify Ban List Dialog, just working out the details.
-        validate.config_file("ban_list.xml", "default_ban_list.xml" ) 
-        configDom = minidom.parse(dir_struct["user"] + 'ban_list.xml')
-        ban_dict = {}
-        for element in configDom.getElementsByTagName('banned'):
-            player = element.getAttribute('name').replace("&", "&amp;").replace("<", "&lt;").replace('"', "&quot;").replace(">", "&gt;")
-            playerIP = element.getAttribute('ip')
-            ban_dict[player] = playerIP
-        print ban_dict
-        ###################
-
     def load_xml(self, xml):
         """ Load configuration from XML data.
             xml (xml) -- xml string to parse """
@@ -346,6 +338,11 @@
         self.build_body()
         self.build_status()
 
+        ### Alpha ###
+        # Ban List Dialog
+        self.BanListDialog = BanListDialog(self)
+        #############
+
         # Server Callbacks
         cb = {}
         cb["log"]        = self.Log
@@ -394,6 +391,8 @@
 
         # Server Configuration Menu
         menu = wx.Menu()
+        menu.Append( MENU_BAN_LIST, 'Ban List', 'Modify Ban List.' )
+        self.Bind(wx.EVT_MENU, self.ModifyBanList, id=MENU_BAN_LIST)
         menu.Append( MENU_START_PING_PLAYERS, 'Start Ping', 'Ping players to validate remote connection.' )
         self.Bind(wx.EVT_MENU, self.PingPlayers, id=MENU_START_PING_PLAYERS)
         menu.Append( MENU_STOP_PING_PLAYERS, 'Stop Ping', 'Stop validating player connections.' )
@@ -591,6 +590,12 @@
         self.SetTitle(__appname__ + "- (running) - (unregistered)")
         wx.EndBusyCursor()
 
+    ### Alpha ###
+    def ModifyBanList(self, event):
+        if self.BanListDialog.IsShown() == True: self.BanListDialog.Hide()
+        else: self.BanListDialog.Show()
+    #############
+
     def PingPlayers( self, event = None ):
         "Ping all players that are connected at a periodic interval, detecting dropped connections."
         wx.BeginBusyCursor()
@@ -606,8 +611,79 @@
     def OnExit(self, event = None):
         """ Quit the program. """
         self.OnStop()
+        self.BanListDialog.Destroy() ### Alpha ###
         wx.CallAfter(self.Destroy)
 
+### Alpha ###
+class BanListDialog(wx.Frame):
+    def __init__(self, parent):
+        super(BanListDialog, self).__init__(parent, -1, "Ban List")
+        icon = wx.Icon(dir_struct["icon"]+'noplayer.gif', wx.BITMAP_TYPE_GIF)
+        self.SetIcon( icon )
+        self.BanList = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_SINGLE_SEL|wx.LC_REPORT|wx.LC_HRULES)
+        sizer = wx.BoxSizer(wx.VERTICAL)
+        sizer.Add(self.BanList, 1, wx.EXPAND)
+        self.BuildList()
+        self.SetSizer(sizer)
+        self.SetAutoLayout(True)
+        self.SetSize((300, 175))
+        self.Bind(wx.EVT_CLOSE, self.Min) 
+        self.Min(None)
+
+        # Ban List Dialog Pop Up Menu, more can be added
+        self.menu = wx.Menu()
+        self.menu.SetTitle( "Modify Ban List" )
+        self.menu.Append( MENU_ADMIN_UNBAN, "Un-Ban Player" )
+
+        # Even Association
+        self.BanList.Bind(wx.EVT_RIGHT_DOWN, self.BanPopupMenu)
+        self.Bind(wx.EVT_MENU, self.BanPopupMenuItem, id=MENU_ADMIN_UNBAN)
+
+    # When we right click, cause our popup menu to appear
+    def BanPopupMenu( self, event ):
+        pos = wx.Point( event.GetX(), event.GetY() )
+        (item, flag) = self.BanList.HitTest( pos )
+        if item > -1:
+            self.selectedItem = item
+            self.PopupMenu( self.menu, pos )
+
+    def BanPopupMenuItem( self, event):
+        menuItem = event.GetId()
+        player = str(self.BanList.GetItemData(self.selectedItem))
+        playerIP = str(self.BanList.GetItem((int(player)), 1).GetText())
+        if menuItem == MENU_ADMIN_UNBAN:
+            server.admin_unban(playerIP)
+            self.BanList.DeleteItem(self.BanList.GetItemData(self.selectedItem))
+            self.BanList.Refresh()   
+
+    def BuildList(self):
+        # Build Dialog Columns
+        self.BanList.ClearAll()
+        self.BanList.InsertColumn(0, "User Name")
+        self.BanList.InsertColumn(1, "IP")
+
+        validate.config_file("ban_list.xml", "default_ban_list.xml" ) 
+        configDom = minidom.parse(dir_struct["user"] + 'ban_list.xml')
+        ban_dict = {}
+        for element in configDom.getElementsByTagName('banned'):
+            player = element.getAttribute('name').replace("&", "&amp;").replace("<", "&lt;").replace('"', "&quot;").replace(">", "&gt;")
+            playerIP = element.getAttribute('ip')
+            ban_dict[player] = playerIP
+        for key in ban_dict:
+            i = self.BanList.InsertImageStringItem( 0, key, 0 )
+            self.BanList.SetStringItem(i, 1, ban_dict[key])
+            self.BanList.RefreshItem(i)
+        self.AutoAdjust()
+
+    def AutoAdjust(self):
+        self.BanList.SetColumnWidth(0, -1)
+        self.BanList.SetColumnWidth(1, -1)
+        self.BanList.Refresh()
+
+    def Min(self, evt):
+        self.Hide()
+###############
+
 class ServerGUIApp(wx.App):
     def OnInit(self):
         # Make sure our image handlers are loaded before we try to display anything
--- a/orpg/orpg_version.py	Thu Sep 24 21:21:49 2009 -0500
+++ b/orpg/orpg_version.py	Fri Sep 25 06:16:37 2009 -0500
@@ -4,7 +4,7 @@
 #BUILD NUMBER FORMAT: "YYMMDD-##" where ## is the incremental daily build index (if needed)
 DISTRO = "Traipse Alpha"
 DIS_VER = "Ornery Orc"
-BUILD = "090924-01"
+BUILD = "090925-00"
 
 # This version is for network capability.
 PROTOCOL_VERSION = "1.2"