Skip to content

Commit

Permalink
update Yuescript. fix IME detach rule. fix UnitAction BT status.
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Feb 5, 2024
1 parent 7d8dd8f commit 9635bcb
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 156 deletions.
35 changes: 24 additions & 11 deletions Assets/Script/Lib/Config.tl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ return function(schema: string, ...: string): DoraConfig
local insertValues: {string: any} = {}
local updateValues: {string: any} = {}
local deleteValues: {string} = {}
local loaded = false
local function notify(event: Struct.RecordEvent, key: string, value: any)
assert(loaded, "Config should be loaded before updating")
if event == "Modified" then
if oldValues[key] == nil then
insertValues[key] = value
Expand Down Expand Up @@ -84,24 +86,35 @@ return function(schema: string, ...: string): DoraConfig
]])
end

rawset(conf as table, "loadAsync", function(self: DoraConfig)
local rows = DB:queryAsync("select name, value_num, value_str from " .. tableName) as {{string, number, string}}
local function initConfig(self: DoraConfig, rows: {{string, number, string}})
local mt = getmetatable(self) as {string}
local fields = {}
for i = 1, #mt do
local fieldName = mt[i]
fields[fieldName] = true
end
for i = 1, #rows do
local key = rows[i][1]
local value: number | string = rows[i][2] or rows[i][3]
oldValues[key] = value
self[key] = value
if fields[key] then
local value: number | string = rows[i][2] or rows[i][3]
oldValues[key] = value
self[key] = value
else
print("Config key \"" .. key .. "\" is no longer exist")
end
end
end

rawset(conf as table, "loadAsync", function(self: DoraConfig)
local rows = DB:queryAsync("select name, value_num, value_str from " .. tableName) as {{string, number, string}}
loaded = true
initConfig(self, rows)
end)

rawset(conf as table, "load", function(self: DoraConfig)
local rows = DB:query("select name, value_num, value_str from " .. tableName) as {{string, number, string}}
for i = 1, #rows do
local key = rows[i][1]
local value: number | string = rows[i][2] or rows[i][3]
oldValues[key] = value
self[key] = value
end
loaded = true
initConfig(self, rows)
end)

rawset(conf as table, "__notify", notify)
Expand Down
5 changes: 3 additions & 2 deletions Assets/Script/Test/TextInput.yue
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ TextInput = Class ((args)->
(pos) <- \convertToWindowSpace Vec2 -label.x + label.width, 0
Keyboard\updateIMEPosHint pos
startEditing = ->
\attachIME!
updateIMEPos!
if !@imeAttached
\attachIME!
updateIMEPos!
.updateDisplayText = (text)=>
textDisplay = text
label.text = text
Expand Down
8 changes: 6 additions & 2 deletions Source/3rdParty/httplib/httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef CPPHTTPLIB_HTTPLIB_H
#define CPPHTTPLIB_HTTPLIB_H

#define CPPHTTPLIB_VERSION "0.15.1"
#define CPPHTTPLIB_VERSION "0.15.2"

/*
* Configuration
Expand Down Expand Up @@ -2421,7 +2421,11 @@ inline bool is_valid_path(const std::string &path) {
// Read component
auto beg = i;
while (i < path.size() && path[i] != '/') {
if (path[i] == '\0') { return false; }
if (path[i] == '\0') {
return false;
} else if (path[i] == '\\') {
return false;
}
i++;
}

Expand Down
9 changes: 1 addition & 8 deletions Source/3rdParty/yuescript/yue_ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1405,15 +1405,8 @@ std::string UnaryExp_t::to_string(void* ud) const {
}
return line;
}
std::string InDiscrete_t::to_string(void* ud) const {
str_list temp;
for (auto value : values.objects()) {
temp.emplace_back(value->to_string(ud));
}
return '[' + join(temp, ", "sv) + (temp.size() == 1 ? ",]"s : "]"s);
}
std::string In_t::to_string(void* ud) const {
return (not_ ? "not "s : ""s) + "in "s + item->to_string(ud);
return (not_ ? "not "s : ""s) + "in "s + value->to_string(ud);
}
std::string ExpListAssign_t::to_string(void* ud) const {
if (action) {
Expand Down
11 changes: 3 additions & 8 deletions Source/3rdParty/yuescript/yue_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class In_t;
class NormalDef_t;
class SpreadListExp_t;
class Comprehension_t;
class Value_t;
} // namespace yue

AST_LEAF(Num)
Expand Down Expand Up @@ -445,16 +446,10 @@ AST_END(UnaryOperator, "unary_op"sv)
AST_LEAF(NotIn)
AST_END(NotIn, "not_in"sv)

AST_NODE(InDiscrete)
ast_ptr<true, Seperator_t> sep;
ast_list<true, Exp_t> values;
AST_MEMBER(InDiscrete, &sep, &values)
AST_END(InDiscrete, "in_discrete"sv)

AST_NODE(In)
ast_ptr<false, NotIn_t> not_;
ast_sel<true, InDiscrete_t, Exp_t> item;
AST_MEMBER(In, &not_, &item)
ast_ptr<true, Value_t> value;
AST_MEMBER(In, &not_, &value)
AST_END(In, "in"sv)

AST_NODE(Assignable)
Expand Down
Loading

0 comments on commit 9635bcb

Please sign in to comment.