Merge pull request #1243 from universe-st/PR-Branch

为《富甲天下》扩展金币变化增加 TOAST 提示。
This commit is contained in:
Spmario233 2024-04-20 22:10:41 +08:00 committed by GitHub
commit 84439e93fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 939 additions and 343 deletions

BIN
audio/effect/coin.mp3 Normal file

Binary file not shown.

BIN
audio/effect/coin_cost.mp3 Normal file

Binary file not shown.

View File

@ -131,8 +131,21 @@ game.import("play", function () {
}
},
game: {
changeCoin: function (num) {
changeCoin: function (num, toast, audio) {
if (typeof num == "number" && ui.coin) {
if (num != 0 && toast !== false) {
ui.create.toast(
`${num > 0 ? "获得" : "花费"} ${Math.abs(
num
)} 金币`
);
}
if (audio !== false) {
game.playAudio(
"effect",
num > 0 ? "coin" : "coin_cost"
);
}
game.saveConfig("coin", lib.config.coin + num);
var str;
if (lib.config.coin_display_playpackconfig == "text") {

43
layout/default/toast.css Normal file
View File

@ -0,0 +1,43 @@
.toast-container {
display: block;
position: absolute;
top: 15%;
left: 50%;
transform: translateX(-50%);
z-index: 9999;
}
.toast {
display: block;
position: absolute;
left: 50%;
transform: translateX(-50%);
background-color: rgba(255, 165, 0, 0.7);
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
color: white;
font-weight: bold;
padding: 10px 20px;
text-align: center;
white-space: nowrap;
width: max-content;
animation: fadeInOut 1500ms ease-in-out forwards;
}
@keyframes fadeInOut {
0% {
opacity: 0;
}
20% {
opacity: 1;
}
80% {
opacity: 1;
}
100% {
opacity: 0;
}
}

View File

@ -1718,7 +1718,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;

View File

@ -3420,7 +3420,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;

View File

@ -4306,7 +4306,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;

View File

@ -1094,7 +1094,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;

View File

@ -22429,7 +22429,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;

View File

@ -2303,7 +2303,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;

View File

@ -2486,7 +2486,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;

View File

@ -841,7 +841,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;
@ -1115,7 +1115,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;
@ -1446,7 +1446,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;
@ -1637,7 +1637,7 @@ game.import("mode", function (lib, game, ui, get, ai, _status) {
ui.cheat2 = ui.create.control("自由选将", function () {
if (this.dialog == _status.event.dialog) {
if (game.changeCoin) {
game.changeCoin(50);
game.changeCoin(10);
}
this.dialog.close();
_status.event.dialog = this.backup;

File diff suppressed because it is too large Load Diff

View File

@ -137,6 +137,10 @@ export class UI {
*/
tempnowuxie;
/**
* @type {HTMLDivElement[]}
*/
toastQueue = [];
* @type {HTMLDivElement}
*/
cardPile;