From ba471084da3701156acd9a4d292a68212dad89b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20P=C3=A5lsson?= Date: Mon, 16 May 2011 17:10:35 +0200 Subject: [PATCH] Fixed fonts and added a dialog to TTT --- games/tic-tac-toe-python/ggskpanel.glade | 135 ----------------------- games/tic-tac-toe-python/kpanel.py | 44 -------- games/tic-tac-toe-python/ttt.py | 43 +++++++- 3 files changed, 42 insertions(+), 180 deletions(-) delete mode 100644 games/tic-tac-toe-python/ggskpanel.glade delete mode 100644 games/tic-tac-toe-python/kpanel.py diff --git a/games/tic-tac-toe-python/ggskpanel.glade b/games/tic-tac-toe-python/ggskpanel.glade deleted file mode 100644 index 3f85df9..0000000 --- a/games/tic-tac-toe-python/ggskpanel.glade +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - 561 - 521 - - - True - - - True - - - True - <span size="x-large">GGS Killtrolpanel</span> - True - - - False - 0 - - - - - True - kill_process_icon.jpg - - - False - False - 1 - - - - - False - False - 0 - - - - - True - 3 - 2 - True - - - All players - True - True - True - - - - - - Coordinator - True - True - True - - - - 1 - 2 - - - - - Dispatcher - True - True - True - - - - 1 - 2 - - - - - Coordinator backup - True - True - True - - - - 1 - 2 - 1 - 2 - - - - - All tables - True - True - True - - - - 2 - 3 - - - - - All GameVMs - True - True - True - - - - 1 - 2 - 2 - 3 - - - - - 1 - - - - - - diff --git a/games/tic-tac-toe-python/kpanel.py b/games/tic-tac-toe-python/kpanel.py deleted file mode 100644 index 84fb5e1..0000000 --- a/games/tic-tac-toe-python/kpanel.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python - -import sys, socket, thread, gobject, getpass, time, os -try: - import pygtk - pygtk.require("2.16") -except: - pass -try: - import gtk - import gtk.glade -except: - sys.exit(1) - -class GGSKPanel: - - def __init__(self): - #Set the Glade file - self.gladefile = "ttt.glade" - self.wTree = gtk.glade.XML(self.gladefile, "window1") - - #Create our dictionay and connect it - dic = { "on_window1_destroy_event" : gtk.main_quit - ,"on_coordinatorButton_clicked" : lambda x: self.terminateProcess("ggs_coordinator") - ,"on_coordinatorBackupButton_clicked" :\ - lambda x: self.terminateProcess("ggs_coordinator_backup") - ,"on_dispatcherButton_clicked" : lambda x: self.terminateProcess("ggs_dispatcher") - } - - self.wTree.signal_autoconnect(dic) - - self.wTree.get_widget("window1").show() - - def terminateProcess(self, process): - os.system("echo \"exit(whereis(%s), 'Bye bye').\" | erl_call -sname ggs -e" % process) - - def setStatus(self, msg): - self.wTree.get_widget("statusbar").push(0, msg) - - -if __name__ == "__main__": - chat = GGSKPanel() - gobject.threads_init() - gtk.main() diff --git a/games/tic-tac-toe-python/ttt.py b/games/tic-tac-toe-python/ttt.py index 6cbe104..71ee0b9 100644 --- a/games/tic-tac-toe-python/ttt.py +++ b/games/tic-tac-toe-python/ttt.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -import sys, socket, thread, gobject, getpass, time, os +import sys, socket, thread, gobject, getpass, time, os, pango try: import pygtk pygtk.require("2.16") @@ -38,6 +38,7 @@ class GGSTTT: self.wTree.signal_autoconnect(dic) self.wTree.get_widget("window1").show() + def doConnect(self): self.setStatus("Not connected") @@ -117,6 +118,15 @@ class GGSTTT: self.wTree.get_widget("x2y0").set_label(msg["DATA"][6]) self.wTree.get_widget("x2y1").set_label(msg["DATA"][7]) self.wTree.get_widget("x2y2").set_label(msg["DATA"][8]) + self.wTree.get_widget("x0y0").get_child().modify_font(pango.FontDescription("sans 48")) + self.wTree.get_widget("x0y1").get_child().modify_font(pango.FontDescription("sans 48")) + self.wTree.get_widget("x0y2").get_child().modify_font(pango.FontDescription("sans 48")) + self.wTree.get_widget("x1y0").get_child().modify_font(pango.FontDescription("sans 48")) + self.wTree.get_widget("x1y1").get_child().modify_font(pango.FontDescription("sans 48")) + self.wTree.get_widget("x1y2").get_child().modify_font(pango.FontDescription("sans 48")) + self.wTree.get_widget("x2y0").get_child().modify_font(pango.FontDescription("sans 48")) + self.wTree.get_widget("x2y1").get_child().modify_font(pango.FontDescription("sans 48")) + self.wTree.get_widget("x2y2").get_child().modify_font(pango.FontDescription("sans 48")) elif msg["Client-Command"] == "defined": self.s.send("Game-Command: hi\n" + "Content-Type: text\n" + @@ -125,6 +135,37 @@ class GGSTTT: elif msg["Client-Command"] == "lusers": print msg gobject.idle_add(self.updateUsers, msg["DATA"]) + elif msg["Client-Command"] == "winner": + message = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, msg["DATA"]) + message.add_button("New game", gtk.RESPONSE_OK) + message.add_button("Exit", gtk.RESPONSE_CLOSE) + resp = message.run() + if resp == gtk.RESPONSE_CLOSE: + sys.exit(1) + message.destroy() + elif resp == gtk.RESPONSE_OK: + print "new game" + self.s.send("Game-Command: new\n" + + "Content-Type: text\n" + + "Content-Length: 0\n"+ + "\n") + message.destroy() + elif msg["Client-Command"] == "loser": + message = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, msg["DATA"]) + message.add_button("New game", gtk.RESPONSE_OK) + message.add_button("Exit", gtk.RESPONSE_CLOSE) + resp = message.run() + if resp == gtk.RESPONSE_CLOSE: + sys.exit(1) + message.destroy() + elif resp == gtk.RESPONSE_OK: + print "new game" + self.s.send("Game-Command: new\n" + + "Content-Type: text\n" + + "Content-Length: 0\n"+ + "\n") + message.destroy() + def connect(self, host,port): print "Connecting"