目前共有1篇帖子。 內容轉換:不轉換▼
 
點擊 回復
245 0
【代码】查看《哀姬・梦魂燕》对话内容的代码
一派護法 十九級
1樓 發表于:2016-8-12 20:15
<?php
require_once('includes/library/rxdata.php');
$folder = iconv('utf-8', 'gb2312', 'D:\\RPG\\Magic Towers\\Works\\拐弯の小街\\哀姬・梦魂燕(3)\\哀姬・梦魂燕\\Data\\');
if (!file_exists($folder)) {
 die('文件夹不存在');
}
function get_map($id) {
 global $folder;
 $file = sprintf('%sMap%03d.rxdata', $folder, $id);
 if (!file_exists($file)) {
  return false;
 }
 return rxdata_load($file);
}
function show_dialogs($map_id, $additional_info = false) {
 global $maps;
 $map = get_map($map_id);
 if (!$map) {
  echo "该地图不存在\n";
  return;
 }
 
 echo '<h2>' . $maps[$map_id]->name . "</h2>\n";
 if ($additional_info) {
  $mapfile = get_map($map_id);
  printf('<p class="info">(ID: %d,尺寸:%dx%d,事件数:%d)</p>', $map_id, $mapfile->width, $mapfile->height, count($map->events));
  unset($mapfile);
 }
 $output = false;
    foreach ($map->events as $event) {
        foreach ($event->pages as $page) {
            $has_dialogs = false;
            foreach ($page->list as $list) {
                if ($list->code == 101 || $list->code == 401) {
                    $has_dialogs = true;
                }
            }
            if (!$has_dialogs) {
                continue;
            }
   $output = true;
           
            $paragraph = '';
            $content_list = array();
            foreach ($page->list as $list) {
                if ($list->code == 101 || $list->code == 401) {
                    $line = $list->parameters[0];
                    $line = preg_replace('/\\\name\[([^\]]+)\]/', '<b>$1:</b>', $line);
                    if (!empty($paragraph) && (substr($line, 0, 3) == '<b>' || $list->code == 101)) {
                        array_push($content_list, $paragraph);
                        $paragraph = '';
                    }
                    $line = preg_replace('/\\\p\[\d+\]/', '', $line);
                    $paragraph .= $line;
                }
            }
            if (!empty($paragraph)) {
                array_push($content_list, $paragraph);
            }
            foreach ($content_list as $paragraph) {
                echo '<p>' . $paragraph . "</p>\n";
            }
            echo '<br>';
        }
    }
 if (!$output) {
  echo "<p class=\"info\">[该地图无对话内容]</p>\n<br>";
 }
}
$maps = rxdata_load($folder . 'MapInfos.rxdata');
ksort($maps);
$additional_title = '';
if (isset($_GET['i'])) {
 $map_id = intval($_GET['i']);
 if (isset($maps[$map_id])) {
  $map_name = $maps[$map_id]->name;
  $additional_title = $map_name . ' - ';
 }
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title><?php echo $additional_title; ?>哀姬·梦魂燕</title>
<link href="styles/main.css" rel="stylesheet" type="text/css">
<style>
.info {
 color: grey;
 font-family: '楷体';
}
</style>
</head>
<body>
<?php
if (isset($map_id)):
 show_dialogs($map_id);
elseif (isset($_GET['all'])):
 foreach ($maps as $id => $map) {
  show_dialogs($id, true);
 }
else:
?>
<p>[<a href="?all">查看全部对话</a>]</p>
<table width="500" border="1" cellpadding="4">
  <tbody>
    <tr>
      <th scope="col">地图ID</th>
      <th scope="col">地图名称</th>
      <th scope="col">地图尺寸</th>
      <th scope="col">事件数量</th>
    </tr>
<?php
foreach ($maps as $id => $map):
 $mapfile = get_map($id);
?>
    <tr align="center">
      <td><?php echo $id; ?></td>
      <td align="left"><a href="?i=<?php echo $id; ?>"><?php echo $map->name; ?></a></td>
      <td><?php printf('%dx%d', $mapfile->width, $mapfile->height); ?></td>
      <td><?php echo count($mapfile->events); ?></td>
    </tr>
<?php endforeach; ?>
  </tbody>
</table>
<?php endif; ?>
</body>
</html>

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
(快捷鍵:Ctrl+Enter)
 

本帖信息

點擊數:245 回複數:0
評論數: ?
作者: 巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2016-8-12 20:15
 
©2010-2024 Arslanbar Ver2.0
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。