查看: 5092|回复: 3

[原创发布] 某些窗口添加鼠标滚轮,触摸移动改变数值

[复制链接]
梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2015-11-25 20:05:52 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 汪汪 于 2015-11-28 09:57 编辑

有的数字操作需要按很多下的,  实在是太累人了.
所以添加了鼠标滚轮和触摸移动..
如果已经有了的话就忽视吧...

[fold=鼠标滚轮,触摸移动,改变数字]

[pre lang="JavaScript" file="Window_wheel.js"]
//=============================================================================
// Window_wheel.js
//=============================================================================
/*:
* @plugindesc 添加通过  鼠标滚轮或触摸移动  改变数字的方法
* @author wangwang
*
* @param NumberInput_z
* @desc 数字输入窗口,默认1个数字所需的移动距离
* @default 50
*
* @param Options_z
* @desc 选项窗口,默认1次操作所需的移动距离
* @default 50
*
* @param ShopNumber_z
* @desc 商店窗口默认1个数字所需的移动距离
* @default 50
*
* @help
* 商店数字 ,数字输入 ,选项窗口
*
*/




(function() {

var Window_wheel_ShopNumber_z = parseInt(PluginManager.parameters("Window_wheel")["ShopNumber_z"], 10);
var Window_wheel_Options_z = parseInt(PluginManager.parameters("Window_wheel")["Options_z"], 10);
var Window_wheel_NumberInput_z= parseInt(PluginManager.parameters("Window_wheel")["NumberInput_z"], 10);




//滚轮相关
//商店
Window_ShopNumber.prototype.scrollUp = function() {
    this.changeNumber(1);
};

Window_ShopNumber.prototype.scrollDown = function() {
    this.changeNumber(-1);
};

//数字输入
Window_NumberInput.prototype.scrollUp = function() {
    this.changeDigit(true);
};
Window_NumberInput.prototype.scrollDown = function() {
    this.changeDigit(false);
};


//滚轮
Window_Options.prototype.scrollUp = function() {
        var index = this.index();
    var symbol = this.commandSymbol(index);
    var value = this.getConfigValue(symbol);
    if (this.isVolumeSymbol(symbol)) {
        value += this.volumeOffset();
        value = value.clamp(0, 100);
        this.changeValue(symbol, value);
    } else {
        this.changeValue(symbol, true);
    }
};

Window_Options.prototype.scrollDown = function() {
    var index = this.index();
    var symbol = this.commandSymbol(index);
    var value = this.getConfigValue(symbol);
    if (this.isVolumeSymbol(symbol)) {
        value -= this.volumeOffset();
        value = value.clamp(0, 100);
        this.changeValue(symbol, value);
    } else {
        this.changeValue(symbol, false);
    }
};




//触摸相关

//商店
Window_ShopNumber.prototype.processTouch = function() {
    if (this.isOpenAndActive()) {
        if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
            this._touching = true;
            this.onTouch(true);
            this.Touchmovest()
        } else if (TouchInput.isTriggered() ){
                    this.Touchmovest()
        } else if (TouchInput.isPressed() && TouchInput.isMoved()){
                this.Touchmove()
        } else if (TouchInput.isCancelled()) {
            if (this.isCancelEnabled()) {
                this.processCancel();
            }
        }
        if (this._touching) {
            if (TouchInput.isPressed()) {
                this.onTouch(false);
            } else {
                this._touching = false;
            }
        }
    } else {
        this._touching = false;
    }
};



Window_ShopNumber.prototype.Touchmovest = function() {
        this._touch_x = TouchInput.x  
    this._touch_y = TouchInput.y
    this._touch_z = 0
}


Window_ShopNumber.prototype.Touchmove = function () {
    var x = TouchInput.x
        x = x - this._touch_x  
    var y = TouchInput.y
        y = this._touch_y - y

    this._touch_z = this._touch_z || 0

   
    var z = Math.floor((x+y)/ Window_wheel_ShopNumber_z)
    if (!isNaN(z)){
            if (this._touch_z !== z){
                        this.changeNumber(z-this._touch_z)
                        this._touch_z = z
            }
        }
}


//选项
Window_Options.prototype.processTouch = function() {
    if (this.isOpenAndActive()) {
        if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
            this._touching = true;
            this.onTouch(true);
        } else if (TouchInput.isTriggered()&& !this.isTouchedInsideFrame()  ){
                    this.Touchmovest()
        } else if (TouchInput.isPressed()&& !this.isTouchedInsideFrame() && TouchInput.isMoved()){
                this.Touchmove()
        } else if (TouchInput.isCancelled()) {
            if (this.isCancelEnabled()) {
                this.processCancel();
            }
        }
        if (this._touching) {
            if (TouchInput.isPressed()) {
                this.onTouch(false);
            } else {
                this._touching = false;
            }
        }
    } else {
        this._touching = false;
    }
};




Window_Options.prototype.Touchmovest = function() {
        this._touch_x = TouchInput.x  
    this._touch_y = TouchInput.y
    this._touch_z = 0
}


Window_Options.prototype.Touchmove = function () {
       
    var x = TouchInput.x
        x = x - this._touch_x  
        
    var y = TouchInput.y
        y = this._touch_y - y

    this._touch_z = this._touch_z || 0
   
    var z = Math.floor((x+y)/ Window_wheel_Options_z)
    if (!isNaN(z)){
            if (this._touch_z !== z){
                if (this._touch_z < z){
                        for (var i = this._touch_z ;i<z ;i++){
                                         this.scrollUp()
                        }
                        this._touch_z = z
                }else if(this._touch_z > z){
                        for (var i = this._touch_z ;i>z ;i--){
                                         this.scrollDown()
                        }
                        this._touch_z = z
                }  
            }
    }
}


//数字输入
Window_NumberInput.prototype.processTouch = function() {
    if (this.isOpenAndActive()) {
        if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
            this._touching = true;
            this.onTouch(true);
        } else if (TouchInput.isTriggered()&& !this.isTouchedInsideFrame() ){
                    this.Touchmovest()
        } else if (TouchInput.isPressed()&& !this.isTouchedInsideFrame() && TouchInput.isMoved()){
                this.Touchmove()
        } else if (TouchInput.isCancelled()) {
            if (this.isCancelEnabled()) {
                this.processCancel();
            }
        }
        if (this._touching) {
            if (TouchInput.isPressed()) {
                this.onTouch(false);
            } else {
                this._touching = false;
            }
        }
    } else {
        this._touching = false;
    }
};




Window_NumberInput.prototype.Touchmovest = function() {
        this._touch_x = TouchInput.x  
    this._touch_y = TouchInput.y
    this._touch_z = 0
}


Window_NumberInput.prototype.Touchmove = function () {
    var x = TouchInput.x
        x = x - this._touch_x  
        
    var y = TouchInput.y
        y = this._touch_y - y

    this._touch_z = this._touch_z || 0
    var z = Math.floor((x+y)/ Window_wheel_NumberInput_z )
    if (!isNaN(z)){
            if (this._touch_z !== z){
                if (this._touch_z < z){
                        for (var i = this._touch_z ;i<z ;i++){
                                         this.changeDigit(true)
                        }
                        this._touch_z = z
                }else if(this._touch_z > z){
                        for (var i = this._touch_z ;i>z ;i--){
                                         this.changeDigit(false)
                        }
                        this._touch_z = z
                }  
            }
    }
}
































})();
[/pre]


[/fold]

评分

参与人数 2梦石 +1 赞 +1 收起 理由
橘子吖 + 1 我很赞同
余烬之中 + 1 原创发布

查看全部评分

梦石
0
星屑
50
在线时间
289 小时
注册时间
2014-12-12
回帖
138
发表于 2015-11-26 18:49:46 | 显示全部楼层
作用不大,毕竟如果制作过的人都懂,...

点评

没有面给  发表于 2020-6-16 10:01
PPT 制作
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部