马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
仅供抛砖引玉,写法什么的还有很多优化的地方,目前也不知道会不会有什么神秘的bug(仅在837中测试过,欢迎补充测试结果)
我们不伟大的新人LH在看完伟大的烈烈评价画廊后,有感而发:
我之前参考过黑凤梨老师制作的nvl手机制作方法,在实际测试下来发现了以下问题:
1.无法保存对话(例如A说aaa,你退出这个界面再进来,发现这句话没了)
2.调用手机页面后,假如对话中途退出手机页面再返回,他会吞对话
由于个人对nvl的了解不多,不知道如何改善这些问题,所以我想到重构手机界面用viewport(实际上用的是vpgrid)+text来实现对话
首先先用一个非常简单的方式来实现对话,word即为对话文字,posi即为对话位置(分为-1(对方发送),0(位于中间,类似系统提醒),1(己方发送))
[RenPy] 纯文本查看 复制代码 init -1 python:
class pt():
def __init__(self,word,posi):
self.word = word
self.posi = posi
然后我们要写一个列表套列表[RenPy] 纯文本查看 复制代码 default lh_ptxt0 = []
default lh_ptxt1 = [
pt("114514",0),
pt("我是LH,不是烈烈",1),
pt("我是烈烈,不是龙叔",1),
]
default lh_ptxt2 = [
pt("你是谁?",-1),
pt("你从哪里来?",-1),
pt("你要到哪里去?",-1),
pt("I am the storm that is approaching",1),
pt("I am the shadow on the moon at night",1),
pt("I am the watcher of the skies",1),
pt("I am the wind and the rain",1),
pt("I am FULL OF POWER!!!!!",1)
]
default lh_ptxt3 = []
default lh_pt = [lh_ptxt1,lh_ptxt2,lh_ptxt3]
rt,lh为对话角色名,ptxt0为已阅读过的文字(或可视为已展示过的文字),lh_pt为对话合集,ptxt1,ptxt2,ptxt3为三段对话
同时我们要加入一个判断条件[RenPy] 纯文本查看 复制代码 default lh_chat_req = [False,False,False]
来判断pt里哪一块对话可以推进
接下来是大量石山代码
[RenPy] 纯文本查看 复制代码 image bg1 = Solid("#338fc4")
screen choosescreen():
frame:
xsize 680
align(0.5,0.5)
top_padding 200
bottom_padding 200
background "bg1"
viewport:
mousewheel True
id "phonetext"
yinitial 1.0
vbox:
spacing 50
#anchor(0.5,0.5)
#xpos(0.5)
for i in allnames:
imagebutton:
#xanchor(0.5)
#xalign(0.5)
idle "images/phone/%s_xiaotu.png" % i
hover "images/phone/%s_xiaotu_hover.png" % i
action SetVariable("tnames",i),Show("phonet")
在这里选择要和谁聊天(tnames),设置imagebutton
另外这里目前还没对齐,imagebutton不会居中,持续修复中(实在不行你们就拿那个xoffset凑合凑合(?
[RenPy] 纯文本查看 复制代码 screen phonet():
modal True
$ then_read = 0
if renpy.get_screen("phonet"):
$ ptxt0 = globals()["%s_ptxt0" % tnames] #获得该角色已阅读的对话
$ chat_req = globals()["%s_chat_req" % tnames] #获得该角色可解锁对话的True False列表
$ pt_character = globals()["%s_pt" % tnames] #获得该角色的全部对话
$ has_read_text = len(ptxt0) #获得该角色已阅读的对话句数
for i in range(len(pt_character)):
$ a = sum(len(sublist1) for sublist1 in pt_character[:i])
$ b = sum(len(sublist2) for sublist2 in pt_character[:i+1])
if a <= has_read_text < b:
$ then_read = i
break
if chat_req[then_read] == True:
$ idx = has_read_text - sum(len(sublist3) for sublist3 in pt_character[:then_read])
if 0 <= idx < len(pt_character[then_read]):
key "mouseup_1" action [Function(ptxt0.append, pt_character[then_read][idx])]
$ globals()["%s_ptxt0" % tnames] = ptxt0
frame:
xsize 680
align(0.5,0.5)
top_padding 200
bottom_padding 200
background "bg1"
viewport:
mousewheel True
id "phonetext"
yinitial 1.0
vbox:
spacing 50
for i in ptxt0:
if i.posi == 1:
hbox:
add "images/phone/me_icon.png" xpos 600 ypos 5
frame:
background Frame("images/phone/send_base.png",xmaximum = 355,xalign = 1.0)
padding (20,10)
xpos (450 + 90 - 10)
xanchor 1.0
text '[i.word]' style "words"
elif i.posi == -1:
hbox:
add "images/phone/%s_icon.png" % tnames xpos 50 ypos 5
frame:
background Frame("images/phone/text_base.png",xmaximum = 355,xalign = 1.0)
padding(20,10)
xpos (300 - 250 + 10)
xanchor 0.0
text '[i.word]' style "words"
elif i.posi == 0:
frame:
background None
xpos 340
xanchor 0.5
text "[i.word]" style "nrwords"
imagebutton:
pos(500,900)
xysize(50,50)
idle "bg1"
action [Hide("phonet"),Show("choosescreen")]
style words:
size 32
color "#ffffff"
outlines [(1,"#000000",0,0)]
xsize 300
style nrwords:
size 28
color "#5c5c5c"
outlines [(1,"#ffffff",0,0)]
xmaximum 600
这里一开始前面那个for里你看到的突兀的两个a,b变量是用来确定对话进行到哪一部分了,从角色_ptxt0中获取长度再获取角色_pt中前i段和前i+1段总对话句数
下面if xxx = True那句是用来判断是否解锁了该段对话,然后通过一些神秘的手段(和上面有点像,都是获取对话句数来推进)来显示对话
顺便,他还会自己根据tnames匹配头像,还会根据对话长度来调整对话框大小(里面xmaximum = 355是一行最大长度,增大一行可显示更多文字,反之则更少)
如果想解锁某段对话,则在label里输入[RenPy] 纯文本查看 复制代码 $ lh_chat_req[0] = True
来解锁(例如上述代码即为解锁角色“lh”的第一段对话)
目前还没有做新消息提醒,正在持续开发中
欢迎各位大佬优化,指出bug并更正
|