added text on map

This commit is contained in:
Ayush Saini 2021-04-02 20:53:19 +05:30
parent 91af4a8027
commit bfb5dd8ec3
7 changed files with 91 additions and 4 deletions

View file

@ -210,6 +210,8 @@ class Map(Actor):
# Set various globals.
gnode = _ba.getactivity().globalsnode
import ba
from tools import textonmap
textonmap.textonmap()

View file

@ -2,8 +2,9 @@
def filter_chat_message(msg,client_id):
from chatHandle import handlechat
return msg
return handlechat.filter_chat_message(msg,client_id)
def on_app_launch():
#something
@ -13,4 +14,4 @@ def score_screen_on_begin(_stats):
def playerspaz_init(player):
#add tag,rank,effect

View file

@ -0,0 +1,8 @@
{
"textonmap":
{
"top watermark":"Welcome to server \n ip 192.168.0.1",
"bottom left watermark":"join discord for fun",
"center highlights":["message 1","message 2","message 3"]
}
}

View file

@ -1 +1,19 @@
# Released under the MIT License. See LICENSE for details.
# Released under the MIT License. See LICENSE for details.
settings={}
def get_setting():
global settings
if settings=={}:
f=open("setting.json","r")
dat=json.loads(f.read())
settings=dat
f.close()
return settings
def commit():
global settings
f=open("setting.json",'w')
json.dump(setting,f,indent=4)
f.close()

View file

@ -1 +1,59 @@
# Released under the MIT License. See LICENSE for details.
# Released under the MIT License. See LICENSE for details.
#TODO need to set coordinates of text node , move timer values to settings.json
from ba._enums import TimeType
import ba
import setting
class textonmap:
def __init__(self):
self.index=0;
_textonmap=setting.get_setting()['textonmap']
self.highlights=_textonmap['center highlights']
left=_textonmap['bottom left watermark']
top=_textonmap['top watermark']
self.timerr=ba.Timer(8,self.highlights,repeat=True)
self.left_watermark(left)
self.top_message(top)
def highlights(self):
hg=_ba.newnode('text',
attrs={
'text': self.highlights[self.index],
'flatness': 1.0,
'h_align': 'center',
'v_attach':'bottom',
'scale':1,
'position':(0,138),
'color':(1,1,1)
})
self.delt=ba.Timer(7,hg.delete)
self.index=int((self.index+1)%len(self.highlights))
def left_watermark(self,text):
hg=_ba.newnode('text',
attrs={
'text': text,
'flatness': 1.0,
'h_align': 'left',
'v_attach':'bottom',
'scale':1,
'position':(0,138),
'color':(1,1,1)
})
def top_message(self,text):
txt=_ba.newnode('text',
attrs={
'text': text,
'flatness': 1.0,
'h_align': 'center',
'v_attach':'top',
'scale':1,
'position':(0,138),
'color':(1,1,1)
})