Constant world info keys

This commit is contained in:
Gnome Ann 2021-08-24 13:45:20 -04:00
parent ce59c9d399
commit 2a7c6244cb
6 changed files with 129 additions and 14 deletions

View File

@ -664,6 +664,10 @@ def get_message(msg):
vars.worldinfo[msg['data']]["selective"] = True
elif(msg['cmd'] == 'wiseloff'):
vars.worldinfo[msg['data']]["selective"] = False
elif(msg['cmd'] == 'wiconstanton'):
vars.worldinfo[msg['data']]["constant"] = True
elif(msg['cmd'] == 'wiconstantoff'):
vars.worldinfo[msg['data']]["constant"] = False
elif(msg['cmd'] == 'sendwilist'):
commitwi(msg['data'])
elif(msg['cmd'] == 'aidgimport'):
@ -1469,7 +1473,7 @@ def togglewimode():
#
#==================================================================#
def addwiitem():
ob = {"key": "", "keysecondary": "", "content": "", "num": len(vars.worldinfo), "init": False, "selective": False}
ob = {"key": "", "keysecondary": "", "content": "", "num": len(vars.worldinfo), "init": False, "selective": False, "constant": False}
vars.worldinfo.append(ob);
emit('from_server', {'cmd': 'addwiitem', 'data': ob}, broadcast=True)
@ -1524,6 +1528,7 @@ def commitwi(ar):
vars.worldinfo[ob["num"]]["keysecondary"] = ob["keysecondary"]
vars.worldinfo[ob["num"]]["content"] = ob["content"]
vars.worldinfo[ob["num"]]["selective"] = ob["selective"]
vars.worldinfo[ob["num"]]["constant"] = ob.get("constant", False)
# Was this a deletion request? If so, remove the requested index
if(vars.deletewi >= 0):
del vars.worldinfo[vars.deletewi]
@ -1573,6 +1578,10 @@ def checkworldinfo(txt):
# Scan text for matches on WI keys
wimem = ""
for wi in vars.worldinfo:
if(wi.get("constant", False)):
wimem = wimem + wi["content"] + "\n"
continue
if(wi["key"] != ""):
# Split comma-separated keys
keys = wi["key"].split(",")
@ -1792,12 +1801,13 @@ def saveRequest(savpath):
# Extract only the important bits of WI
for wi in vars.worldinfo:
if(wi["key"] != ""):
if(wi["constant"] or wi["key"] != ""):
js["worldinfo"].append({
"key": wi["key"],
"keysecondary": wi["keysecondary"],
"content": wi["content"],
"selective": wi["selective"]
"selective": wi["selective"],
"constant": wi["constant"]
})
# Write it
@ -1858,7 +1868,8 @@ def loadRequest(loadpath):
"content": wi["content"],
"num": num,
"init": True,
"selective": wi.get("selective", False)
"selective": wi.get("selective", False),
"constant": wi.get("constant", False)
})
num += 1
@ -1976,7 +1987,8 @@ def importgame():
"content": wi["entry"],
"num": num,
"init": True,
"selective": wi.get("selective", False)
"selective": wi.get("selective", False),
"constant": wi.get("constant", False)
})
num += 1
@ -2022,7 +2034,8 @@ def importAidgRequest(id):
"content": wi["entry"],
"num": num,
"init": True,
"selective": wi.get("selective", False)
"selective": wi.get("selective", False),
"constant": wi.get("constant", False)
})
num += 1
@ -2055,7 +2068,8 @@ def wiimportrequest():
"content": wi["entry"],
"num": num,
"init": True,
"selective": wi.get("selective", False)
"selective": wi.get("selective", False),
"constant": wi.get("constant", False)
})
num += 1

View File

@ -189,13 +189,14 @@ function addWiLine(ob) {
<button type=\"button\" class=\"btn btn-success heighthalf hidden\" id=\"btn_widel"+ob.num+"\"></button>\
<button type=\"button\" class=\"btn btn-danger heighthalf hidden\" id=\"btn_wican"+ob.num+"\"></button>\
</div>\
<div class=\"wikey\">\
<div class=\"icon-container wikey\">\
<input class=\"form-control heightfull hidden\" type=\"text\" placeholder=\"Key(s)\" id=\"wikey"+ob.num+"\">\
<input class=\"form-control heighthalf\" type=\"text\" placeholder=\"Primary Key(s)\" id=\"wikeyprimary"+ob.num+"\">\
<input class=\"form-control heighthalf\" type=\"text\" placeholder=\"Secondary Key(s)\" id=\"wikeysecondary"+ob.num+"\">\
<span class=\"constant-key-icon "+(ob.constant ? "constant-key-icon-enabled" : "")+" oi oi-pin\" id=\"constant-key-"+ob.num+"\" title=\"Toggle Constant Key mode (if enabled, this world info entry will always be included in memory)\" aria-hidden=\"true\"></span>\
</div>\
<div class=\"wientry\">\
<textarea class=\"form-control\" id=\"wientry"+ob.num+"\" placeholder=\"What To Remember\">"+ob.content+"</textarea>\
<textarea class=\"layer-bottom form-control\" id=\"wientry"+ob.num+"\" placeholder=\"What To Remember\">"+ob.content+"</textarea>\
</div>\
<div class=\"wiselective\">\
<button type=\"button\" class=\"btn btn-success heightfull hidden\" id=\"btn_wiselon"+ob.num+"\">Enable Selective Mode</button>\
@ -209,10 +210,11 @@ function addWiLine(ob) {
<button type=\"button\" class=\"btn btn-success heighthalf hidden\" id=\"btn_widel"+ob.num+"\"></button>\
<button type=\"button\" class=\"btn btn-danger heighthalf hidden\" id=\"btn_wican"+ob.num+"\"></button>\
</div>\
<div class=\"wikey\">\
<div class=\"icon-container wikey\">\
<input class=\"form-control heightfull\" type=\"text\" placeholder=\"Key(s)\" id=\"wikey"+ob.num+"\">\
<input class=\"form-control heighthalf hidden\" type=\"text\" placeholder=\"Primary Key(s)\" id=\"wikeyprimary"+ob.num+"\">\
<input class=\"form-control heighthalf hidden\" type=\"text\" placeholder=\"Secondary Key(s)\" id=\"wikeysecondary"+ob.num+"\">\
<span class=\"constant-key-icon "+(ob.constant ? "constant-key-icon-enabled" : "")+" oi oi-pin\" id=\"constant-key-"+ob.num+"\" title=\"Toggle Constant Key mode (if enabled, this world info entry will always be included in memory)\" aria-hidden=\"true\"></span>\
</div>\
<div class=\"wientry\">\
<textarea class=\"form-control\" id=\"wientry"+ob.num+"\" placeholder=\"What To Remember\">"+ob.content+"</textarea>\
@ -239,13 +241,14 @@ function addWiLine(ob) {
<button type=\"button\" class=\"btn btn-success heighthalf hidden\" id=\"btn_widel"+ob.num+"\"></button>\
<button type=\"button\" class=\"btn btn-danger heighthalf hidden\" id=\"btn_wican"+ob.num+"\">X</button>\
</div>\
<div class=\"wikey\">\
<div class=\"icon-container wikey\">\
<input class=\"form-control heightfull hidden\" type=\"text\" placeholder=\"Key(s)\" id=\"wikey"+ob.num+"\">\
<input class=\"form-control heighthalf hidden\" type=\"text\" placeholder=\"Primary Key(s)\" id=\"wikeyprimary"+ob.num+"\">\
<input class=\"form-control heighthalf hidden\" type=\"text\" placeholder=\"Secondary Key(s)\" id=\"wikeysecondary"+ob.num+"\">\
<span class=\"constant-key-icon oi oi-pin hidden\" id=\"constant-key-"+ob.num+"\" title=\"Toggle Constant Key mode (if enabled, this world info entry will always be included in memory)\" aria-hidden=\"true\"></span>\
</div>\
<div class=\"wientry\">\
<textarea class=\"form-control hidden\" id=\"wientry"+ob.num+"\" placeholder=\"What To Remember\"></textarea>\
<textarea class=\"layer-bottom form-control hidden\" id=\"wientry"+ob.num+"\" placeholder=\"What To Remember\">"+ob.content+"</textarea>\
</div>\
<div class=\"wiselective\">\
<button type=\"button\" class=\"btn btn-success heightfull hidden\" id=\"btn_wiselon"+ob.num+"\">Enable Selective Mode</button>\
@ -258,6 +261,18 @@ function addWiLine(ob) {
});
}
// Assign actions to other elements
wientry_onfocus = function () {
$("#constant-key-"+ob.num).addClass("constant-key-icon-clickthrough");
}
wientry_onfocusout = function () {
$("#constant-key-"+ob.num).removeClass("constant-key-icon-clickthrough");
}
$("#wikey"+ob.num).on("focus", wientry_onfocus);
$("#wikeyprimary"+ob.num).on("focus", wientry_onfocus);
$("#wikeysecondary"+ob.num).on("focus", wientry_onfocus);
$("#wikey"+ob.num).on("focusout", wientry_onfocusout);
$("#wikeyprimary"+ob.num).on("focusout", wientry_onfocusout);
$("#wikeysecondary"+ob.num).on("focusout", wientry_onfocusout);
$("#btn_wican"+ob.num).on("click", function () {
hideWiDeleteConfirm(ob.num);
});
@ -270,10 +285,20 @@ function addWiLine(ob) {
$("#btn_wiseloff"+ob.num).on("click", function () {
disableWiSelective(ob.num);
});
$("#constant-key-"+ob.num).on("click", function () {
element = $("#constant-key-"+ob.num);
if(element.hasClass("constant-key-icon-enabled")) {
socket.send({'cmd': 'wiconstantoff', 'data': ob.num});
element.removeClass("constant-key-icon-enabled")
} else {
socket.send({'cmd': 'wiconstanton', 'data': ob.num});
element.addClass("constant-key-icon-enabled");
}
});
}
function expandWiLine(num) {
show([$("#wikey"+num), $("#wientry"+num), $("#btn_wiselon"+num)]);
show([$("#wikey"+num), $("#wientry"+num), $("#constant-key-"+num), $("#btn_wiselon"+num)]);
$("#btn_wi"+num).html("X");
$("#btn_wi"+num).off();
// Tell server the WI entry was initialized
@ -297,6 +322,7 @@ function enableWiSelective(num) {
hide([$("#btn_wiselon"+num), $("#wikey"+num)]);
// Tell server the WI entry is now selective
socket.send({'cmd': 'wiselon', 'data': num});
$("#wikeyprimary"+num).val($("#wikey"+num).val());
show([$("#wikeyprimary"+num), $("#wikeysecondary"+num), $("#btn_wiseloff"+num)]);
}
@ -304,6 +330,7 @@ function disableWiSelective(num) {
hide([$("#btn_wiseloff"+num), $("#wikeyprimary"+num), $("#wikeysecondary"+num)]);
// Tell server the WI entry is now non-selective
socket.send({'cmd': 'wiseloff', 'data': num});
$("#wikey"+num).val($("#wikeyprimary"+num).val());
show([$("#btn_wiselon"+num), $("#wikey"+num)]);
}
@ -436,11 +463,12 @@ function returnWiList(ar) {
var list = [];
var i;
for(i=0; i<ar.length; i++) {
var ob = {"key": "", "keysecondary": "", "content": "", "num": ar[i], "selective": false};
var ob = {"key": "", "keysecondary": "", "content": "", "num": ar[i], "selective": false, "constant": false};
ob.selective = $("#wikeyprimary"+ar[i]).css("display") != "none"
ob.key = ob.selective ? $("#wikeyprimary"+ar[i]).val() : $("#wikey"+ar[i]).val();
ob.keysecondary = $("#wikeysecondary"+ar[i]).val()
ob.content = $("#wientry"+ar[i]).val();
ob.constant = $("#constant-key-"+ar[i]).hasClass("constant-key-icon-enabled");
list.push(ob);
}
socket.send({'cmd': 'sendwilist', 'data': list});

View File

@ -507,6 +507,54 @@ chunk, chunk * {
z-index: 2;
}
.icon-container {
position: relative;
}
.constant-key-icon {
position: absolute !important;
top: 5px !important;
right: 5px !important;
z-index: 1;
transform: rotate(20deg);
-moz-transform: rotate(20deg);
-webkit-transform: rotate(20deg);
-ms-transform: rotate(20deg);
-o-transform: rotate(20deg);
opacity: 0%;
}
*:hover > .constant-key-icon {
opacity: 40%;
}
.constant-key-icon:hover {
opacity: 65%;
cursor: pointer;
}
.constant-key-icon-enabled {
color: #3bf723;
opacity: 65%
}
*:hover > .constant-key-icon-enabled {
opacity: 65%;
}
.constant-key-icon-enabled:hover {
opacity: 100%
}
.constant-key-icon-clickthrough {
opacity: 0% !important;
pointer-events: none;
}
.constant-key-icon-clickthrough.constant-key-icon-enabled {
opacity: 35% !important;
}
.loadlistheader {
padding-left: 10px;
display: grid;

24
static/open-iconic-bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

BIN
static/open-iconic.woff Normal file

Binary file not shown.

View File

@ -13,6 +13,7 @@
<link rel="stylesheet" href="static/bootstrap.min.css">
<link rel="stylesheet" href="static/bootstrap-toggle.min.css">
<link rel="stylesheet" href="static/custom.css?ver=0.15.0g">
<link rel="stylesheet" href="static/open-iconic-bootstrap.min.css">
</head>
<body>
<div class="container">