forked from diandian157/decadeUI--mx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd310e3
commit daefe2b
Showing
10 changed files
with
39,917 additions
and
23,156 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,142 +1,116 @@ | ||
"use strict"; | ||
decadeModule.import(function (lib, game, ui, get, ai, _status) { | ||
decadeUI.component = { | ||
slider: function (min, max, value) { | ||
var slider = document.createElement("input"); | ||
var onchange = function () { | ||
var percent = | ||
((slider.value - slider.min) / (slider.max - slider.min)) * 100; | ||
slider.style.backgroundSize = percent + "% " + "100%"; | ||
}; | ||
decadeUI.component = { | ||
slider: function (min, max, value) { | ||
var slider = document.createElement("input"); | ||
var onchange = function () { | ||
var percent = ((slider.value - slider.min) / (slider.max - slider.min)) * 100; | ||
slider.style.backgroundSize = percent + "% " + "100%"; | ||
}; | ||
|
||
var valueProp = Object.getOwnPropertyDescriptor( | ||
slider.__proto__, | ||
"value" | ||
); | ||
Object.defineProperties(slider, { | ||
value: { | ||
configurable: true, | ||
get: function () { | ||
return valueProp.get.call(this); | ||
}, | ||
set: function (value) { | ||
valueProp.set.call(this, value); | ||
onchange(); | ||
}, | ||
}, | ||
}); | ||
var valueProp = Object.getOwnPropertyDescriptor(slider.__proto__, "value"); | ||
Object.defineProperties(slider, { | ||
value: { | ||
configurable: true, | ||
get: function () { | ||
return valueProp.get.call(this); | ||
}, | ||
set: function (value) { | ||
valueProp.set.call(this, value); | ||
onchange(); | ||
}, | ||
}, | ||
}); | ||
|
||
slider.className = "slider"; | ||
slider.type = "range"; | ||
slider.addEventListener("input", onchange); | ||
slider.className = "slider"; | ||
slider.type = "range"; | ||
slider.addEventListener("input", onchange); | ||
|
||
slider.min = typeof min == "number" ? min : 0; | ||
slider.max = typeof max == "number" ? max : 100; | ||
slider.value = typeof value == "number" ? value : (max - min) * 0.5; | ||
return slider; | ||
}, | ||
chatBox: function () { | ||
var box = decadeUI.dialog.create("chat-box folded"); | ||
box.container = decadeUI.dialog.create("container", box); | ||
box.operation = decadeUI.dialog.create("operation", box); | ||
box.content = decadeUI.dialog.create("content", box.container); | ||
slider.min = typeof min == "number" ? min : 0; | ||
slider.max = typeof max == "number" ? max : 100; | ||
slider.value = typeof value == "number" ? value : (max - min) * 0.5; | ||
return slider; | ||
}, | ||
chatBox: function () { | ||
var box = decadeUI.dialog.create("chat-box folded"); | ||
box.container = decadeUI.dialog.create("container", box); | ||
box.operation = decadeUI.dialog.create("operation", box); | ||
box.content = decadeUI.dialog.create("content", box.container); | ||
|
||
box.operation.fold = decadeUI.dialog.create( | ||
"fold-button", | ||
box.operation, | ||
"button" | ||
); | ||
box.operation.input = decadeUI.dialog.create( | ||
"chat-input", | ||
box.operation, | ||
"input" | ||
); | ||
box.operation.sticker = decadeUI.dialog.create( | ||
"sticker-button", | ||
box.operation, | ||
"button" | ||
); | ||
box.operation.send = decadeUI.dialog.create( | ||
"send-button", | ||
box.operation, | ||
"button" | ||
); | ||
box.operation.fold = decadeUI.dialog.create("fold-button", box.operation, "button"); | ||
box.operation.input = decadeUI.dialog.create("chat-input", box.operation, "input"); | ||
box.operation.sticker = decadeUI.dialog.create("sticker-button", box.operation, "button"); | ||
box.operation.send = decadeUI.dialog.create("send-button", box.operation, "button"); | ||
|
||
box.operation.fold.innerHTML = "…"; | ||
box.operation.sticker.innerHTML = "表情"; | ||
box.operation.send.innerHTML = "发送"; | ||
box.operation.fold.innerHTML = "…"; | ||
box.operation.sticker.innerHTML = "表情"; | ||
box.operation.send.innerHTML = "发送"; | ||
|
||
box.addEntry = function (info) { | ||
var text = decadeUI.dialog.create("chat-text", box.content); | ||
text.innerHTML = | ||
'<span class="sender">' + | ||
info[0] + | ||
"</span>:" + | ||
'<span class="text">' + | ||
info[1] + | ||
"</span>"; | ||
if (box.overrideEntry) box.overrideEntry(info); | ||
box.content.scrollTop = box.content.scrollHeight; | ||
}; | ||
box.addEntry = function (info) { | ||
var text = decadeUI.dialog.create("chat-text", box.content); | ||
text.innerHTML = '<span class="sender">' + info[0] + "</span>:" + '<span class="text">' + info[1] + "</span>"; | ||
if (box.overrideEntry) box.overrideEntry(info); | ||
box.content.scrollTop = box.content.scrollHeight; | ||
}; | ||
|
||
box.addEntry._origin = box; | ||
box.addEntry._origin = box; | ||
|
||
box.sendInputText = function () { | ||
if (input.value) { | ||
var player = game.me; | ||
var str = input.value; | ||
if (!player) { | ||
if (game.connectPlayers) { | ||
if (game.online) { | ||
for (var i = 0; i < game.connectPlayers.length; i++) { | ||
if (game.connectPlayers[i].playerid == game.onlineID) { | ||
player = game.connectPlayers[i]; | ||
break; | ||
} | ||
} | ||
} else { | ||
player = game.connectPlayers[0]; | ||
} | ||
} | ||
} | ||
if (!player) return; | ||
if (game.online) { | ||
game.send("chat", game.onlineID, str); | ||
} else { | ||
lib.element.player.chat.call(player, str); | ||
} | ||
input.value = ""; | ||
_status.chatValue = ""; | ||
} | ||
}; | ||
box.sendInputText = function () { | ||
if (input.value) { | ||
var player = game.me; | ||
var str = input.value; | ||
if (!player) { | ||
if (game.connectPlayers) { | ||
if (game.online) { | ||
for (var i = 0; i < game.connectPlayers.length; i++) { | ||
if (game.connectPlayers[i].playerid == game.onlineID) { | ||
player = game.connectPlayers[i]; | ||
break; | ||
} | ||
} | ||
} else { | ||
player = game.connectPlayers[0]; | ||
} | ||
} | ||
} | ||
if (!player) return; | ||
if (game.online) { | ||
game.send("chat", game.onlineID, str); | ||
} else { | ||
lib.element.player.chat.call(player, str); | ||
} | ||
input.value = ""; | ||
_status.chatValue = ""; | ||
} | ||
}; | ||
|
||
var input = box.operation.input; | ||
var input = box.operation.input; | ||
|
||
box.operation.fold.addEventListener("click", function () { | ||
if (box.classList.contains("folded")) { | ||
box.operation.fold.innerHTML = "<<"; | ||
box.classList.remove("folded"); | ||
} else { | ||
box.operation.fold.innerHTML = "…"; | ||
box.classList.add("folded"); | ||
} | ||
}); | ||
box.operation.fold.addEventListener("click", function () { | ||
if (box.classList.contains("folded")) { | ||
box.operation.fold.innerHTML = "<<"; | ||
box.classList.remove("folded"); | ||
} else { | ||
box.operation.fold.innerHTML = "…"; | ||
box.classList.add("folded"); | ||
} | ||
}); | ||
|
||
box.operation.send.addEventListener("click", function () { | ||
box.sendInputText(); | ||
input.focus(); | ||
}); | ||
box.operation.send.addEventListener("click", function () { | ||
box.sendInputText(); | ||
input.focus(); | ||
}); | ||
|
||
input.addEventListener("change", function (e) { | ||
_status.chatValue = input.value; | ||
}); | ||
input.addEventListener("change", function (e) { | ||
_status.chatValue = input.value; | ||
}); | ||
|
||
input.addEventListener("keydown", function (e) { | ||
if (e.keyCode == 13) box.sendInputText(); | ||
e.stopPropagation(); | ||
}); | ||
input.addEventListener("keydown", function (e) { | ||
if (e.keyCode == 13) box.sendInputText(); | ||
e.stopPropagation(); | ||
}); | ||
|
||
return box; | ||
}, | ||
}; | ||
return box; | ||
}, | ||
}; | ||
}); |
Oops, something went wrong.