Miliardo 发表于 2006-7-21 21:09:24

[KCDDP]Krkr推进委员会专题站点公开

为了给各位Kirikiri用户提供一个专门的交流空间,同时也为了迎接KAGeXpress 3的发布,KeyFC同人发展促进会准备了新的吉里吉里/KAG专题站点。
欢迎各位对Kirikiri/KAG有兴趣的朋友来这里访问。

地址:http://krkr.keyfc.net

以后的技巧收集、教程等都会以这里为主发布。

CountD 发表于 2006-10-12 18:20:09

在得到无数教程及shawind样的帮助,并在犯了无数傻错误之后的成果。
自定义弹出询问框。
包括窗口背景及按钮用图片代替。
自定义消息字体(需要把字体打成tft包)及颜色,居中和换行。
换行方式:在需要换行的地方插入换行符\\n。
一般的类似存储、退出等询问是在mainwindow中修改文字。


// YesNoDialog.tjs - はい/いいえを選択するダイアログボックス
// Copyright (C)2001-2005, W.Dee and contributors改変.配布は自由です

class YesNoDialogWindow extends Window
{
    var yesButton; // [はい] ボタン
    var noButton; // [いいえ] ボタン

    var result = false; // no:false yes:true

    function YesNoDialogWindow(message, cap)
    {
      super.Window();

      // メインウィンドウから cursor**** の情報をとってくる
      if(global.Window.mainWindow !== null &&
            typeof global.Window.mainWindow.cursorDefault != "undefined")
            this.cursorDefault = global.Window.mainWindow.cursorDefault;
      if(global.Window.mainWindow !== null &&
            typeof global.Window.mainWindow.cursorPointed != "undefined")
            this.cursorPointed = global.Window.mainWindow.cursorPointed;

      // 外見の調整
      borderStyle = bsNone; //无风格窗口
      innerSunken = false;

      // プライマリレイヤの作成
      add(new Layer(this, null));

      // プライマリのマウスカーソルを設定
      if(typeof this.cursorDefault !== "undefined")
            primaryLayer.cursor = cursorDefault;
                  primaryLayer.loadImages("pop.jpg"); //对话框的底图
                  primaryLayer.setSizeToImageSize();
                  primaryLayer.type = ltTransparent;
                  
      // 文字样式设定      
      primaryLayer.font.mapPrerenderedFont("font.tft");//选择特殊字体包
      
      var tw = primaryLayer.font.getTextWidth(message);
      var th = primaryLayer.font.getTextHeight(message);
      
            var max_tw = 0;
            var sum_th = 0;
            var messages = message.split('\\n');
            for (var i=0; i < messages.count; i++){
            var lw = primaryLayer.font.getTextWidth(messages);
            var lh = primaryLayer.font.getTextHeight(messages);
            if (lw > max_tw)
            max_tw = tw;
            sum_th += lh + 0; // 行間が必要なら+0より大きくする
            }
            tw = max_tw;
            th = sum_th;

      var w =primaryLayer.width;
      var h = primaryLayer.height;

      setInnerSize(w, h);

      primaryLayer.width = w;
      primaryLayer.height = h;

      // ウィンドウ位置の調整
      if(global.Window.mainWindow !== null && global.Window.mainWindow isvalid)
      {
            var win = global.Window.mainWindow;
            var l, t;
            l = ((win.width - width)>>1) + win.left;
            t = ((win.height - height)>>1) + win.top;
            if(l < 0) l = 0;
            if(t < 0) t = 0;
            if(l + width > System.screenWidth) l = System.screenWidth - width;
            if(t + height > System.screenHeight) t = System.screenHeight - height;
            setPos(l, t);
      }
      else
      {
            setPos((System.screenWidth - width)>>1, (System.screenHeight - height)>>1);
      }

      // message文字的描绘
            var msgpos_y = 60;
            for (var i=0; i < messages.count; i++){
               var lw = primaryLayer.font.getTextWidth(messages);
               var lh = primaryLayer.font.getTextHeight(messages);
               var msgpos_x = (w - lw)\\2;
            primaryLayer.drawText(msgpos_x, msgpos_y, messages,0x804040);//修改颜色
               msgpos_y += lh + 10; // 调整行间距
            }

      
            primaryLayer.font.unmapPrerenderedFont(); //还原字体样式

      // Yesボタン
      add(yesButton = new ButtonLayer(this, primaryLayer));
      yesButton.loadImages("yes.jpg",);//确认按钮的图片
      yesButton.top = 167;//调整按钮显示位置
      yesButton.left = 40;//调整按钮显示位置
      yesButton.visible = true;


      // Noボタン
      add(noButton = new ButtonLayer(this, primaryLayer));
      noButton.loadImages("no.jpg",);//取消按钮的图片
      noButton.top = 167;//调整按钮显示位置
      noButton.left = 220;//调整按钮显示位置
      noButton.visible = true;

    }

    function finalize()
    {
      super.finalize(...);
    }

    function action(ev)
    {
      // action
      if(ev.type == "onClick")
      {
            if(ev.target == yesButton)
            {
                result = true;
                close();
            }
            else if(ev.target == noButton)
            {
                result = false;
                close();
            }
      }
      else if(ev.type == "onKeyDown" && ev.target === this)
      {
            // パッド入力に対応する処理
            switch(ev.key)
            {
            case VK_PADLEFT:
                yesButton.focus();
                break;
            case VK_PADRIGHT:
                noButton.focus();
                break;
            case VK_PAD1:
                if(focusedLayer == yesButton)
                {
                  result = true;
                  close();
                }
                else if(focusedLayer == noButton)
                {
                  result = false;
                  close();
                }
                break;
            case VK_PAD2:
                result = false;
                close();
                break;
            }
      }
    }

    function onKeyDown(key, shift)
    {
      super.onKeyDown(...);
      if(key == VK_ESCAPE)
      {
            // ESC キーが押された
            // 「いいえ」として処理
            result = false;
            close();
      }
    }
}

// Yes か No かはっきりさせる関数
function askYesNo(message, caption = "確認")
{
    var win = new YesNoDialogWindow(message, caption);
    win.showModal();
    var res = win.result;
    invalidate win;
    return res;
}


~效果图~
http://bbs.rpgchina.com/p_w_upload/Fid_46/46_681_8f8ddc0098c51ab.jpg

orenda 发表于 2007-2-5 19:33:15

很不错了,我学一下。
请问有其他源码可以提供吗?除了美化,更关心热区,存档一类的
页: [1]
查看完整版本: [KCDDP]Krkr推进委员会专题站点公开