Project1

标题: 关于标题变更 [打印本页]

作者: 双织    时间: 2014-7-10 16:42
标题: 关于标题变更
请问该如何做出当某一结局开启以后变更标题的名称呢?
也就是更改这个地方:

QQ图片20140710164049.jpg (1.95 KB, 下载次数: 45)

QQ图片20140710164049.jpg

作者: VIPArcher    时间: 2014-7-10 17:02
本帖最后由 VIPArcher 于 2014-7-10 18:09 编辑


如果是要在游戏里改标题的名字可以用事件脚本指令(这个只适用于默认标题)
  1. $data_system.game_title = "游戏名"
复制代码
(反正我是不会啦
别在意这楼,看楼下。
作者: taroxd    时间: 2014-7-10 17:29
本帖最后由 taroxd 于 2014-7-10 17:51 编辑

读取目录下的 Game.ini 文件,然后改了它……

我试了一下,Ruby1.9 似乎并不支持 GB2312 编码。因此请使用英文标题……

在事件脚本中调用这个就可以修改标题了。

RUBY 代码复制
  1. file = File.open(
  2. 'Game.ini', 'r+')
  3. string = file.read.sub(
  4. /^Title=.*/,
  5. 'Title=new_title')
  6. file.rewind
  7. file.write string
  8. file.close

作者: Sylvania    时间: 2014-7-10 17:49
  1. SetWindowText = Win32API.new 'user32', 'SetWindowText', 'lp', 'l'
  2. SetWindowText.call hwnd, "Hello World"
复制代码
即时刷新,前提是你知道怎样获取窗口句柄(论坛上有)

PS: 中文标题需要转码才能正常显示
作者: kuerlulu    时间: 2014-7-10 18:39
RUBY 代码复制
  1. #==============================================================================
  2. # ■ String
  3. #------------------------------------------------------------------------------
  4. #  为字符串追加编码转换的机能。
  5. #==============================================================================
  6. # 参考:
  7. #[url]http://msdn.microsoft.com/en-us/library/windows/desktop/dd319072[/url](v=vs.85).aspx
  8. #[url]http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130[/url](v=vs.85).aspx
  9. #[url]http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756[/url](v=vs.85).aspx
  10. #==============================================================================
  11. class String
  12.   #--------------------------------------------------------------------------
  13.   # ● 常量定义
  14.   #--------------------------------------------------------------------------
  15.   MultiByteToWideChar = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  16.   WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
  17.   Codepages = {
  18.     :System => 0,     :UTF7   => 65000, :UTF8   => 65001,
  19.     :S_JIS  => 932,   :GB2312 => 936,   :BIG5   => 950,
  20.   }
  21.   #--------------------------------------------------------------------------
  22.   # ● 伪 iconv 编码转换
  23.   #--------------------------------------------------------------------------
  24.   #     s : 原始编码,可使用 Codepages 中的符号或者直接使用代码页值。
  25.   #     d : 目标编码,同上。
  26.   #--------------------------------------------------------------------------
  27.   def iconv s, d
  28.     src  = s.is_a?(Symbol)? Codepages[s] : s
  29.     dest = d.is_a?(Symbol)? Codepages[d] : d
  30.  
  31.     len = MultiByteToWideChar.call src, 0, self, -1, nil, 0
  32.     buf = "\0" * (len * 2)
  33.     MultiByteToWideChar.call src, 0, self, -1, buf, buf.size / 2
  34.  
  35.     len = WideCharToMultiByte.call dest, 0, buf, -1, nil, 0, nil, nil
  36.     ret = "\0" * len
  37.     WideCharToMultiByte.call dest, 0, buf, -1, ret, ret.size, nil, nil
  38.  
  39.     self.respond_to?(:force_encoding) ?
  40.     ret.force_encoding("ASCII-8BIT").delete("\000") :
  41.     ret.delete("\000")
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 快捷方式:从 ANSI 转为 UTF-8 编码
  45.   #--------------------------------------------------------------------------
  46.   def s2u
  47.     self.respond_to?(:force_encoding) ?
  48.     iconv(:System, :UTF8).force_encoding("utf-8") :
  49.     iconv(:System, :UTF8)
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● 快捷方式:从 UTF-8 转为 ANSI 编码
  53.   #--------------------------------------------------------------------------
  54.   def u2s
  55.     iconv(:UTF8, :System)
  56.   end
  57. end
  1. class Game_Interpreter
  2.   def title(str)
  3.     t = File.read("Game.ini").s2u.sub(/^Title=.*/) { "Title="+str } .u2s
  4.     File.open("Game.ini", "w") { |f| f.write t }
  5.     exit
  6.   end
  7. end
复制代码
以上 按照第一个脚本在上的顺序插入这两个脚本

然后在事件脚本中输入 title(新的游戏名) # 可以使用中文
此方法被触发后会自动退出游戏, 所以不想玩家觉得太突兀的话还是游戏中给出一些说明(设定)




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1