MCML标记语言
MCML Markup Language
类似HTML的标记语言. 用类似HTML/Java的模式快速开发游戏UI.

什么是MCML?

MCML是MicroCosmos Markup Language的缩写, 是!ParaEngine定义并开发的标记语言. MCML是XML格式, 支持大部分CSS和HTML标记, 可以用来描述社区或游戏中的许多UI, 例如几乎所有windows常用控件, 任务, 道具, 等等. 我们可以将它理解为Web中的HTML. 其中以pe开头的标记是!ParaEngine中所特有的标记, 常常对应一个NPL类库中的UI控件. MCML的渲染器是用NPL脚本编写的, 所以开发者也可以定义自己的Tag.

MCML/NPL 设计模式

MCML提供了一种类似HTML/Java的编程模式, 我们称之为!MCML/NPL Code Behind 模式. 它使得您可以快速开发游戏UI和客户端/服务器逻辑. 同时可以让界面和代码分开, 使用CSS和HTML Tag, 使得产品UI专业且统一. 例如下面的MCML代码: 注意NPL代码既可以直接写在!MCML文件中, 也可以写在外部脚本文件中
<!-- "script/apps/Aquarius/Desktop/LoginPage.html?cmdredirect=" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>LoginPage file, by LiXizhi, 2008/10/27</title>
</head>
<body>
<pe:mcml>
<script src="LoginPage.lua">

</script>
<script type="text/npl"><![CDATA[
    -- MyCompany.Aquarius.LoginPage.OnInit();
    function OnInit()
       local self = document:GetPageCtrl();
       local bRememberPassword = MyCompany.Aquarius.app:ReadConfig("rememberpassword", false);
       self:SetNodeValue("rememberpassword", bRememberPassword);
       if(bRememberPassword) then
           self:SetNodeValue("username", System.User.Name);
           self:SetNodeValue("password", System.User.Password);
       end
    end
    OnInit()
    
    commonlib.echo("script/apps/Aquarius/Desktop/LoginPage.html is depracated");
    
    function OnClickConnect(btnName, values)
        NPL.load("(gl)script/kids/3DMapSystemApp/Login/LoginProcedure.lua");
       paraworld.ShowMessage("正在验证用户身份, 请等待...", function() 
           OnClickConnect(btnName, values)
       end, _guihelper.MessageBoxButtons.RetryCancel)
       
       local pageCtrl = document:GetPageCtrl();
       MyCompany.Aquarius.LoginPage.Proc_Authentication(values, function ()
           if(pageCtrl) then
               paraworld.ShowMessage();
               local cmdredirect = pageCtrl:GetRequestParam("cmdredirect");
               pageCtrl:CloseWindow()
               
               if(cmdredirect) then
                   System.App.Commands.Call(cmdredirect);
               end
           end
       end, true);
    end
    
    -- register
    function OnClickRegister()
        document:GetPageCtrl():CloseWindow();
        System.App.Commands.Call("Profile.Aquarius.Register");
    end
]]></script>
<!--user is not logged in, show some news-->
<pe:if-is-user uid="notloggedinuser">
  <pe:editor>
    <div style="margin:10px;color:#006600">请输入用户名和密码</div>
    <hr />
    <div style="width:120px;float:left;text-align:right">用户名:</div><input type="text" name="username" style="width:125px"/><br />
    <div style="width:120px;float:left;text-align:right">密码:</div><input type="password" name="password" style="width:125px"/><br />
    <div style="margin-left:120px;"><input type="checkbox" name="rememberpassword"/>记住密码</div><br />
    <div style="width:120px;float:left;text-align:right">域名: </div><select name="domain">
        <option selected="selected" value="pala5.com">缺省域名</option>
        <option value="pala5.com">pala5.com</option>
        <option value="test.pala5.cn">test.pala5.cn</option>
     </select>
     <hr />
     <div style="margin-left:120px;">
         <input DefaultButton="true" class="defaultbutton" type="submit" name="login" value="登录" onclick="OnClickConnect"/>
         <div style="float:left;margin-left:10px;"><a type="button" onclick="OnClickRegister">注册新用户</a></div>
     </div>
  </pe:editor>
</pe:if-is-user>

<!--user is online, show home page-->
<pe:if-is-user uid="loggedinuser">
    <div style="background:;padding:10px" height="100%" width="100%" class="box">
        <div style="float:left;">
            <pe:profile-photo uid="loggedinuser" width="120" height="90"/>
        </div>
        <div style="float:left;margin-left:10px">
            <a href="script/kids/3DMapSystemApp/profiles/ProfileRegPage.html" target="_mcmlblank"><pe:name uid="loggedinuser" useyou="false" linked="false" style="font-weight:bold;"/><span>(编辑档案)</span></a><span style="margin:5px">您已经成功登陆!</span><br />
            <hr />
        </div>
        <hr />
        <a href="LoggedInHomePage.html" target="_mcmlblank"><img style="margin-top:2px;margin-right:10px; background:url(Texture/3DMapSystem/common/rainbow.png);width:16px;height:16px;" />打开我的首页</a>
        <hr />
    </div>
</pe:if-is-user> 

</pe:mcml> 
</body>
</html>

Copyright © ParaEngine Corporation 2009 All Rights Reserved 派瑞安擎公司 版权所有。粤ICP备12027041号