Now ggs_gamevm_e uses ggs_db so store/lookup nicks.
This commit is contained in:
parent
87df33fd47
commit
c4f244e778
6 changed files with 20 additions and 327 deletions
|
|
@ -1,317 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<glade-interface>
|
|
||||||
<!-- interface-requires gtk+ 2.16 -->
|
|
||||||
<!-- interface-naming-policy project-wide -->
|
|
||||||
<widget class="GtkWindow" id="window1">
|
|
||||||
<child>
|
|
||||||
<widget class="GtkVBox" id="vbox1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkEntry" id="txtCalc">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="invisible_char">•</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkTable" id="table1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="n_rows">5</property>
|
|
||||||
<property name="n_columns">4</property>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="button1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btnDiv">
|
|
||||||
<property name="label" translatable="yes">/</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnDiv_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="right_attach">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btnMul">
|
|
||||||
<property name="label" translatable="yes">*</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnMul_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">2</property>
|
|
||||||
<property name="right_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btnMin">
|
|
||||||
<property name="label" translatable="yes">-</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnMin_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">3</property>
|
|
||||||
<property name="right_attach">4</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btn7">
|
|
||||||
<property name="label" translatable="yes">7</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btn7_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="bottom_attach">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btn8">
|
|
||||||
<property name="label" translatable="yes">8</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btn8_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="right_attach">2</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="bottom_attach">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btn9">
|
|
||||||
<property name="label" translatable="yes">9</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btn9_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">2</property>
|
|
||||||
<property name="right_attach">3</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="bottom_attach">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btnPlus">
|
|
||||||
<property name="label" translatable="yes">+</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnPlus_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">3</property>
|
|
||||||
<property name="right_attach">4</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="bottom_attach">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btn4">
|
|
||||||
<property name="label" translatable="yes">4</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btn4_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="top_attach">2</property>
|
|
||||||
<property name="bottom_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btn5">
|
|
||||||
<property name="label" translatable="yes">5</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btn5_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="right_attach">2</property>
|
|
||||||
<property name="top_attach">2</property>
|
|
||||||
<property name="bottom_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btn6">
|
|
||||||
<property name="label" translatable="yes">6</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btn6_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">2</property>
|
|
||||||
<property name="right_attach">3</property>
|
|
||||||
<property name="top_attach">2</property>
|
|
||||||
<property name="bottom_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btnDel">
|
|
||||||
<property name="label" translatable="yes">←</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnDel_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">3</property>
|
|
||||||
<property name="right_attach">4</property>
|
|
||||||
<property name="top_attach">2</property>
|
|
||||||
<property name="bottom_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btn1">
|
|
||||||
<property name="label" translatable="yes">1</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btn1_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
<property name="bottom_attach">4</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btn2">
|
|
||||||
<property name="label" translatable="yes">2</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btn2_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="right_attach">2</property>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
<property name="bottom_attach">4</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btn3">
|
|
||||||
<property name="label" translatable="yes">3</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btn3_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">2</property>
|
|
||||||
<property name="right_attach">3</property>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
<property name="bottom_attach">4</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btnEq">
|
|
||||||
<property name="label" translatable="yes">=</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnEq_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">3</property>
|
|
||||||
<property name="right_attach">4</property>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
<property name="bottom_attach">4</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btn0">
|
|
||||||
<property name="label" translatable="yes">0</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btn0_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="top_attach">4</property>
|
|
||||||
<property name="bottom_attach">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="button18">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="right_attach">2</property>
|
|
||||||
<property name="top_attach">4</property>
|
|
||||||
<property name="bottom_attach">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="button19">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">2</property>
|
|
||||||
<property name="right_attach">3</property>
|
|
||||||
<property name="top_attach">4</property>
|
|
||||||
<property name="bottom_attach">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="btnConnect">
|
|
||||||
<property name="label" translatable="yes">☎</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnConnect_clicked"/>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">3</property>
|
|
||||||
<property name="right_attach">4</property>
|
|
||||||
<property name="top_attach">4</property>
|
|
||||||
<property name="bottom_attach">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkStatusbar" id="statusbar">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="spacing">2</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
</glade-interface>
|
|
||||||
|
|
@ -26,6 +26,7 @@ class GGSChat:
|
||||||
dic = {"on_window1_destroy_event" : gtk.main_quit
|
dic = {"on_window1_destroy_event" : gtk.main_quit
|
||||||
, "on_sendButton_clicked" : lambda x: self.chat()
|
, "on_sendButton_clicked" : lambda x: self.chat()
|
||||||
, "on_entry_activate" : lambda x : self.chat()
|
, "on_entry_activate" : lambda x : self.chat()
|
||||||
|
, "on_nickBox_activate" : lambda x : self.changeNick()
|
||||||
, "on_chatBox_focus" : lambda x, y: self.wTree.get_widget("entry").grab_focus()
|
, "on_chatBox_focus" : lambda x, y: self.wTree.get_widget("entry").grab_focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,10 +35,21 @@ class GGSChat:
|
||||||
self.wTree.get_widget("nickBox").set_text(getpass.getuser())
|
self.wTree.get_widget("nickBox").set_text(getpass.getuser())
|
||||||
self.wTree.get_widget("window1").show()
|
self.wTree.get_widget("window1").show()
|
||||||
self.wTree.get_widget("entry").grab_focus()
|
self.wTree.get_widget("entry").grab_focus()
|
||||||
|
self.changeNick()
|
||||||
|
|
||||||
def setStatus(self, msg):
|
def setStatus(self, msg):
|
||||||
self.wTree.get_widget("statusbar").push(0, msg)
|
self.wTree.get_widget("statusbar").push(0, msg)
|
||||||
|
|
||||||
|
def changeNick(self):
|
||||||
|
params = self.wTree.get_widget("nickBox").get_text()
|
||||||
|
self.s.send("Game-Command: nick\n" +
|
||||||
|
"Token: %s\n" % self.token +
|
||||||
|
"Content-Type: text\n" +
|
||||||
|
"Content-Length: %s\n" % len(params)+
|
||||||
|
"\n"+
|
||||||
|
params)
|
||||||
|
|
||||||
|
|
||||||
def chat(self):
|
def chat(self):
|
||||||
exp = self.wTree.get_widget("entry").get_text()
|
exp = self.wTree.get_widget("entry").get_text()
|
||||||
nick = self.wTree.get_widget("nickBox").get_text()
|
nick = self.wTree.get_widget("nickBox").get_text()
|
||||||
|
|
@ -45,14 +57,13 @@ class GGSChat:
|
||||||
cmdStr = exp[1:].split(" ")
|
cmdStr = exp[1:].split(" ")
|
||||||
cmd = cmdStr[0]
|
cmd = cmdStr[0]
|
||||||
params = ' '.join(cmdStr[1:])
|
params = ' '.join(cmdStr[1:])
|
||||||
self.s.send("Game-Command: %s\n" % exp[1:] +
|
self.s.send("Game-Command: %s\n" % cmd +
|
||||||
"Token: %s\n" % self.token +
|
"Token: %s\n" % self.token +
|
||||||
"Content-Type: text\n" +
|
"Content-Type: text\n" +
|
||||||
"Content-Length: %s\n" % len(params)+
|
"Content-Length: %s\n" % len(params)+
|
||||||
"\n"+
|
"\n"+
|
||||||
params)
|
params)
|
||||||
else:
|
else:
|
||||||
exp = "<%s> %s" % (nick, exp)
|
|
||||||
self.s.send("Game-Command: chat\n"+
|
self.s.send("Game-Command: chat\n"+
|
||||||
"Token: %s\n" % self.token +
|
"Token: %s\n" % self.token +
|
||||||
"Content-Type: text\n"+
|
"Content-Type: text\n"+
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
<property name="invisible_char">•</property>
|
<property name="invisible_char">•</property>
|
||||||
<property name="width_chars">10</property>
|
<property name="width_chars">10</property>
|
||||||
<property name="text" translatable="yes">Anonymous</property>
|
<property name="text" translatable="yes">Anonymous</property>
|
||||||
|
<signal name="activate" handler="on_nickBox_activate"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,3 @@
|
||||||
%%%%----------------------------------------------------
|
|
||||||
%%% @author Mattias Pettersson <mattiaspgames@gmail.com>
|
|
||||||
%%% @copyright 2011 Mattias Pettersson
|
|
||||||
%%% @doc Database for runtime game variable storage.
|
|
||||||
%%% @end
|
|
||||||
|
|
||||||
-module(ggs_db).
|
-module(ggs_db).
|
||||||
-export([init/0,stop/0,setItem/4,getItem/3,removeItem/3,key/3,clear/2,clear/1,length/2]).
|
-export([init/0,stop/0,setItem/4,getItem/3,removeItem/3,key/3,clear/2,clear/1,length/2]).
|
||||||
%-include("ggs_db.hrl").
|
%-include("ggs_db.hrl").
|
||||||
|
|
|
||||||
|
|
@ -46,14 +46,17 @@ do_stuff(Command, Args, Player, Table) ->
|
||||||
"greet" ->
|
"greet" ->
|
||||||
ggs_player:notify(Player, server, "Hello there!\n");
|
ggs_player:notify(Player, server, "Hello there!\n");
|
||||||
"chat" ->
|
"chat" ->
|
||||||
ggs_table:notify_all_players(Table, Args ++ "\n");
|
Nick = ggs_db:getItem(Table, nicks, Player),
|
||||||
|
ggs_table:notify_all_players(Table, "<"++Nick++"> "++ Args ++ "\n");
|
||||||
"uname" ->
|
"uname" ->
|
||||||
Uname = os:cmd("uname -a"),
|
Uname = os:cmd("uname -a"),
|
||||||
ggs_player:notify(Player, server, Uname);
|
ggs_player:notify(Player, server, Uname);
|
||||||
"lusers" ->
|
"lusers" ->
|
||||||
{ok, Players} = ggs_table:get_player_list(Table),
|
{ok, Players} = ggs_table:get_player_list(Table),
|
||||||
ggs_player:notify(Player, server,io_lib:format("~p\n",[Players]));
|
Nicks = lists:map(fun (P) -> ggs_db:getItem(Table, nicks, P) end, Players),
|
||||||
|
ggs_player:notify(Player, server,io_lib:format("~p\n",[Nicks]));
|
||||||
"nick" ->
|
"nick" ->
|
||||||
|
ggs_db:setItem(Table,nicks,Player,Args),
|
||||||
io:format("Changing nickname of ~p to ~p.", [Player, Args]);
|
io:format("Changing nickname of ~p to ~p.", [Player, Args]);
|
||||||
_Other ->
|
_Other ->
|
||||||
ggs_player:notify(Player, server, "I don't know that command..\n")
|
ggs_player:notify(Player, server, "I don't know that command..\n")
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,5 @@
|
||||||
start() ->
|
start() ->
|
||||||
application:start(inets),
|
application:start(inets),
|
||||||
application:start(erlang_js),
|
application:start(erlang_js),
|
||||||
|
ggs_db:init(),
|
||||||
application:start(ggs).
|
application:start(ggs).
|
||||||
|
|
|
||||||
Reference in a new issue