[Release]EmoticonSystem - New management for emoticons

11/12/2012 12:52 lollo_9_1#1
What is it?
EmoticonSystem is a simple code to insert into client to semplify some parts of the implementation of the "emoticons" (not emotion)
In short:
  • It will be possible to implement an emoticon but only edit a tuple declared in constinfo
  • You can also specify whether it can be written in chat or in the list of emoticons (using SHOW and HIDE in the tuple of constinfo)
  • You can see all emoticons implemented (with SHOW) by typing in chat /emoticon


PyGuide (colored: [Only registered and activated users can see links. Click Here To Register...])
Code:
#@================================================================================================@
#@ EmoticonSystem v3 - Created by martysama0134                                                   @
#@================================================================================================@
#in constinfo.py
EmoticonStr="d:/ymir work/effect/etc/emoticon/"
EmoticonTuple=(
	("(Ȳ´ç)",		("SHOW",	EmoticonStr+"sweat.mse")),
	("(µ·)",		("SHOW",	EmoticonStr+"money.mse")),
	("(±â»Ý)",		("SHOW",	EmoticonStr+"happy.mse")),
	("(ÁÁ¾Æ)",		("SHOW",	EmoticonStr+"love_s.mse")),
	("(»ç¶û)",		("SHOW",	EmoticonStr+"love_l.mse")),
	("(ºÐ³ë)",		("SHOW",	EmoticonStr+"angry.mse")),
	("(¾ÆÇÏ)",		("SHOW",	EmoticonStr+"aha.mse")),
	("(¿ì¿ï)",		("SHOW",	EmoticonStr+"gloom.mse")),
	("(Á˼Û)",		("SHOW",	EmoticonStr+"sorry.mse")),
	("(!)",			("SHOW",	EmoticonStr+"!_mix_back.mse")),
	("(?)",			("SHOW",	EmoticonStr+"question.mse")),
	("(fish)",		("SHOW",	EmoticonStr+"fish.mse")),
	#("(buff)",		("HIDE",	"d:/ymir work/effect/etc/buff/buff_symbol1.mse")),
)
EmoticonDict=dict(EmoticonTuple)
#@================================================================================================@
#in playersettingmodule.py
	emo_index=0
	for emo_data in constInfo.EmoticonTuple:
		chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+emo_index, "", emo_data[1][1])
		net.RegisterEmoticonString(emo_data[0])
		emo_index+=1
#in place of:
	#########################################################################################
	## Emoticon
	EmoticonStr = "d:/ymir work/effect/etc/emoticon/"

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+0, "", EmoticonStr+"sweat.mse")
	net.RegisterEmoticonString("(Ȳ´ç)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+1, "", EmoticonStr+"money.mse")
	net.RegisterEmoticonString("(µ·)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+2, "", EmoticonStr+"happy.mse")
	net.RegisterEmoticonString("(±â»Ý)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+3, "", EmoticonStr+"love_s.mse")
	net.RegisterEmoticonString("(ÁÁ¾Æ)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+4, "", EmoticonStr+"love_l.mse")
	net.RegisterEmoticonString("(»ç¶û)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+5, "", EmoticonStr+"angry.mse")
	net.RegisterEmoticonString("(ºÐ³ë)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+6, "", EmoticonStr+"aha.mse")
	net.RegisterEmoticonString("(¾ÆÇÏ)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+7, "", EmoticonStr+"gloom.mse")
	net.RegisterEmoticonString("(¿ì¿ï)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+8, "", EmoticonStr+"sorry.mse")
	net.RegisterEmoticonString("(Á˼Û)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+9, "", EmoticonStr+"!_mix_back.mse")
	net.RegisterEmoticonString("(!)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+10, "", EmoticonStr+"question.mse")
	net.RegisterEmoticonString("(?)")

	chrmgr.RegisterEffect(chrmgr.EFFECT_EMOTICON+11, "", EmoticonStr+"fish.mse")
	net.RegisterEmoticonString("(fish)")


	## Emoticon
	#########################################################################################
#@================================================================================================@
#in uichat.py
# su def __SendChatPacket
		if text=='/emoticon':
			chat.AppendChat(chat.CHAT_TYPE_INFO, "[UiChat-Info]Emoticon list:")
			emo_ind=0
			for emo_char in constInfo.EmoticonTuple:
				if(emo_char[1][0]=="SHOW"):
					chat.AppendChat(chat.CHAT_TYPE_INFO, "%d: %s"%(emo_ind,emo_char[0]))
					emo_ind+=1
			return
		try:
			if(constInfo.EmoticonDict[text][0]=="HIDE"):
				return
		except KeyError:
			pass
#@================================================================================================@
#@                                             Extra                                              @
#@================================================================================================@
#in game.py
# on def __ServerCommand_Build into dict serverCommandList add this element:
			"sendchatpacket":	self.__SendChatPacket,
# before def BINARY_ServerCommand_Run(self, line)
	def __SendChatPacket(self, text):
		net.SendChatPacket(text.replace(";;;"," "), chat.CHAT_TYPE_TALKING)
#@================================================================================================@
#@                                              END                                               @
#@================================================================================================@
To call an emoticon using lua: (if extra inserted)
Code:
cmdchat("sendchatpacket (fish)")
--normal phrase
local mex="This is a phrase with spaces!"
cmdchat("sendchatpacket "..string.gsub(mex," ",";;;"))
Warnings:
  • You can use the command sendchatpacket to write every text (emoticon or normal phrase)
  • Each space in cmdchat is equivalent to a argument to send! (I escaped it with ;;; in the example and code)
11/12/2012 13:09 .Rebel#2
with that way can be possible make dances and etc tanks bro
11/12/2012 13:20 _NBA*~*#3
really nice^^

but which mob is in the background?

mfg
11/12/2012 13:32 iAbarth#4
Geile Sache Good Work :D Was Das Für Mob Rechts ? :D Der Drache Oder was da war ^^
11/12/2012 13:37 xCPx#5
creating dances is much easier....
11/12/2012 19:16 .Seriously#6
Was hat das für ein Sin?
11/12/2012 19:18 I3rockencyde#7
It looks ver nice!
Thank You!