Compare commits
5 Commits
bf22569019
...
4c8c649779
Author | SHA1 | Date |
---|---|---|
sfan5 | 4c8c649779 | |
Lars Mueller | b164e16d1b | |
SmallJoker | 8fab406c28 | |
sfan5 | 5eb45e1ea0 | |
sfan5 | 76dbd0d2d0 |
|
@ -150,29 +150,6 @@ jobs:
|
|||
run: |
|
||||
./bin/minetestserver --run-unittests
|
||||
|
||||
# Build without freetype (client-only)
|
||||
clang_9_no_freetype:
|
||||
name: "clang_9 (FREETYPE=0)"
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install deps
|
||||
run: |
|
||||
source ./util/ci/common.sh
|
||||
install_linux_deps clang-9
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
./util/ci/build.sh
|
||||
env:
|
||||
CC: clang-9
|
||||
CXX: clang++-9
|
||||
CMAKE_FLAGS: "-DENABLE_FREETYPE=0 -DBUILD_SERVER=0"
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
./bin/minetest --run-unittests
|
||||
|
||||
docker:
|
||||
name: "Docker image"
|
||||
runs-on: ubuntu-18.04
|
||||
|
|
18
README.md
|
@ -135,7 +135,8 @@ Compiling
|
|||
| GCC | 4.9+ | Can be replaced with Clang 3.4+ |
|
||||
| CMake | 3.5+ | |
|
||||
| IrrlichtMt | - | Custom version of Irrlicht, see https://github.com/minetest/irrlicht |
|
||||
| SQLite3 | 3.0+ | |
|
||||
| Freetype | 2.0+ | |
|
||||
| SQLite3 | 3+ | |
|
||||
| Zstd | 1.0+ | |
|
||||
| LuaJIT | 2.0+ | Bundled Lua 5.1 is used if not present |
|
||||
| GMP | 5.0.0+ | Bundled mini-GMP is used if not present |
|
||||
|
@ -143,7 +144,7 @@ Compiling
|
|||
|
||||
For Debian/Ubuntu users:
|
||||
|
||||
sudo apt install g++ make libc6-dev cmake libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev
|
||||
sudo apt install g++ make libc6-dev cmake libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev libluajit-5.1-dev
|
||||
|
||||
For Fedora users:
|
||||
|
||||
|
@ -247,7 +248,6 @@ General options and their default values:
|
|||
MinSizeRel - Release build with -Os passed to compiler to make executable as small as possible
|
||||
ENABLE_CURL=ON - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http
|
||||
ENABLE_CURSES=ON - Build with (n)curses; Enables a server side terminal (command line option: --terminal)
|
||||
ENABLE_FREETYPE=ON - Build with FreeType2; Allows using TTF fonts
|
||||
ENABLE_GETTEXT=ON - Build with Gettext; Allows using translations
|
||||
ENABLE_GLES=OFF - Build for OpenGL ES instead of OpenGL (requires support by IrrlichtMt)
|
||||
ENABLE_LEVELDB=ON - Build with LevelDB; Enables use of LevelDB map backend
|
||||
|
@ -273,10 +273,10 @@ Library specific options:
|
|||
EGL_INCLUDE_DIR - Only if building with GLES; directory that contains egl.h
|
||||
EGL_LIBRARY - Only if building with GLES; path to libEGL.a/libEGL.so
|
||||
EXTRA_DLL - Only on Windows; optional paths to additional DLLs that should be packaged
|
||||
FREETYPE_INCLUDE_DIR_freetype2 - Only if building with FreeType 2; directory that contains an freetype directory with files such as ftimage.h in it
|
||||
FREETYPE_INCLUDE_DIR_ft2build - Only if building with FreeType 2; directory that contains ft2build.h
|
||||
FREETYPE_LIBRARY - Only if building with FreeType 2; path to libfreetype.a/libfreetype.so/freetype.lib
|
||||
FREETYPE_DLL - Only if building with FreeType 2 on Windows; path to libfreetype.dll
|
||||
FREETYPE_INCLUDE_DIR_freetype2 - Directory that contains files such as ftimage.h
|
||||
FREETYPE_INCLUDE_DIR_ft2build - Directory that contains ft2build.h
|
||||
FREETYPE_LIBRARY - Path to libfreetype.a/libfreetype.so/freetype.lib
|
||||
FREETYPE_DLL - Only on Windows; path to libfreetype-6.dll
|
||||
GETTEXT_DLL - Only when building with gettext on Windows; paths to libintl + libiconv DLLs
|
||||
GETTEXT_INCLUDE_DIR - Only when building with gettext; directory that contains iconv.h
|
||||
GETTEXT_LIBRARY - Only when building with gettext on Windows; path to libintl.dll.a
|
||||
|
@ -337,7 +337,6 @@ vcpkg install zlib zstd curl[winssl] openal-soft libvorbis libogg libjpeg-turbo
|
|||
- **Don't forget about IrrlichtMt.** The easiest way is to clone it to `lib/irrlichtmt` as described in the Linux section.
|
||||
- `curl` is optional, but required to read the serverlist, `curl[winssl]` is required to use the content store.
|
||||
- `openal-soft`, `libvorbis` and `libogg` are optional, but required to use sound.
|
||||
- `freetype` is optional, it allows true-type font rendering.
|
||||
- `luajit` is optional, it replaces the integrated Lua interpreter with a faster just-in-time interpreter.
|
||||
- `gmp` and `jsoncpp` are optional, otherwise the bundled versions will be compiled
|
||||
|
||||
|
@ -429,8 +428,7 @@ cmake .. \
|
|||
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 \
|
||||
-DCMAKE_FIND_FRAMEWORK=LAST \
|
||||
-DCMAKE_INSTALL_PREFIX=../build/macos/ \
|
||||
-DRUN_IN_PLACE=FALSE \
|
||||
-DENABLE_FREETYPE=TRUE -DENABLE_GETTEXT=TRUE
|
||||
-DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE
|
||||
|
||||
make -j$(nproc)
|
||||
make install
|
||||
|
|
|
@ -91,7 +91,6 @@ LOCAL_CFLAGS += \
|
|||
-DENABLE_GLES=1 \
|
||||
-DUSE_CURL=1 \
|
||||
-DUSE_SOUND=1 \
|
||||
-DUSE_FREETYPE=1 \
|
||||
-DUSE_LEVELDB=0 \
|
||||
-DUSE_LUAJIT=1 \
|
||||
-DUSE_GETTEXT=1 \
|
||||
|
|
|
@ -125,17 +125,21 @@ os.tmpname = function()
|
|||
end
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
function menu_render_worldlist()
|
||||
local retval = ""
|
||||
function menu_render_worldlist(show_gameid)
|
||||
local retval = {}
|
||||
local current_worldlist = menudata.worldlist:get_list()
|
||||
|
||||
local row
|
||||
for i, v in ipairs(current_worldlist) do
|
||||
if retval ~= "" then retval = retval .. "," end
|
||||
retval = retval .. core.formspec_escape(v.name) ..
|
||||
" \\[" .. core.formspec_escape(v.gameid) .. "\\]"
|
||||
row = v.name
|
||||
if show_gameid == nil or show_gameid == true then
|
||||
row = row .. " [" .. v.gameid .. "]"
|
||||
end
|
||||
retval[#retval+1] = core.formspec_escape(row)
|
||||
|
||||
end
|
||||
|
||||
return retval
|
||||
return table.concat(retval, ",")
|
||||
end
|
||||
|
||||
function menu_handle_key_up_down(fields, textlist, settingname)
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
--with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
local worldname = ""
|
||||
-- cf. tab_local, the gamebar already provides game selection so we hide the list from here
|
||||
local hide_gamelist = PLATFORM ~= "Android"
|
||||
|
||||
local function table_to_flags(ftable)
|
||||
-- Convert e.g. { jungles = true, caves = false } to "jungles,nocaves"
|
||||
|
@ -31,9 +32,8 @@ local function strflag(flags, flag)
|
|||
return (flags[flag] == true) and "true" or "false"
|
||||
end
|
||||
|
||||
local cb_caverns = { "caverns", fgettext("Caverns"), "caverns",
|
||||
local cb_caverns = { "caverns", fgettext("Caverns"),
|
||||
fgettext("Very large caverns deep in the underground") }
|
||||
local tt_sea_rivers = fgettext("Sea level rivers")
|
||||
|
||||
local flag_checkboxes = {
|
||||
v5 = {
|
||||
|
@ -41,39 +41,38 @@ local flag_checkboxes = {
|
|||
},
|
||||
v7 = {
|
||||
cb_caverns,
|
||||
{ "ridges", fgettext("Rivers"), "ridges", tt_sea_rivers },
|
||||
{ "mountains", fgettext("Mountains"), "mountains" },
|
||||
{ "floatlands", fgettext("Floatlands (experimental)"), "floatlands",
|
||||
{ "ridges", fgettext("Rivers"), fgettext("Sea level rivers") },
|
||||
{ "mountains", fgettext("Mountains") },
|
||||
{ "floatlands", fgettext("Floatlands (experimental)"),
|
||||
fgettext("Floating landmasses in the sky") },
|
||||
},
|
||||
carpathian = {
|
||||
cb_caverns,
|
||||
{ "rivers", fgettext("Rivers"), "rivers", tt_sea_rivers },
|
||||
{ "rivers", fgettext("Rivers"), fgettext("Sea level rivers") },
|
||||
},
|
||||
valleys = {
|
||||
{ "altitude-chill", fgettext("Altitude chill"), "altitude_chill",
|
||||
{ "altitude_chill", fgettext("Altitude chill"),
|
||||
fgettext("Reduces heat with altitude") },
|
||||
{ "altitude-dry", fgettext("Altitude dry"), "altitude_dry",
|
||||
{ "altitude_dry", fgettext("Altitude dry"),
|
||||
fgettext("Reduces humidity with altitude") },
|
||||
{ "humid-rivers", fgettext("Humid rivers"), "humid_rivers",
|
||||
{ "humid_rivers", fgettext("Humid rivers"),
|
||||
fgettext("Increases humidity around rivers") },
|
||||
{ "vary-river-depth", fgettext("Vary river depth"), "vary_river_depth",
|
||||
{ "vary_river_depth", fgettext("Vary river depth"),
|
||||
fgettext("Low humidity and high heat causes shallow or dry rivers") },
|
||||
},
|
||||
flat = {
|
||||
cb_caverns,
|
||||
{ "hills", fgettext("Hills"), "hills" },
|
||||
{ "lakes", fgettext("Lakes"), "lakes" },
|
||||
{ "hills", fgettext("Hills") },
|
||||
{ "lakes", fgettext("Lakes") },
|
||||
},
|
||||
fractal = {
|
||||
{ "terrain", fgettext("Additional terrain"), "terrain",
|
||||
{ "terrain", fgettext("Additional terrain"),
|
||||
fgettext("Generate non-fractal terrain: Oceans and underground") },
|
||||
},
|
||||
v6 = {
|
||||
{ "trees", fgettext("Trees and jungle grass"), "trees" },
|
||||
{ "flat", fgettext("Flat terrain"), "flat" },
|
||||
{ "mudflow", fgettext("Mud flow"), "mudflow",
|
||||
fgettext("Terrain surface erosion") },
|
||||
{ "trees", fgettext("Trees and jungle grass") },
|
||||
{ "flat", fgettext("Flat terrain") },
|
||||
{ "mudflow", fgettext("Mud flow"), fgettext("Terrain surface erosion") },
|
||||
-- Biome settings are in mgv6_biomes below
|
||||
},
|
||||
}
|
||||
|
@ -105,38 +104,26 @@ local function create_world_formspec(dialogdata)
|
|||
"button[4.75,2.5;3,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
|
||||
end
|
||||
|
||||
local current_mg = dialogdata.mg
|
||||
local mapgens = core.get_mapgen_names()
|
||||
|
||||
local current_seed = core.settings:get("fixed_map_seed") or ""
|
||||
local current_mg = core.settings:get("mg_name")
|
||||
local gameid = core.settings:get("menu_last_game")
|
||||
|
||||
local flags = {
|
||||
main = core.settings:get_flags("mg_flags"),
|
||||
v5 = core.settings:get_flags("mgv5_spflags"),
|
||||
v6 = core.settings:get_flags("mgv6_spflags"),
|
||||
v7 = core.settings:get_flags("mgv7_spflags"),
|
||||
fractal = core.settings:get_flags("mgfractal_spflags"),
|
||||
carpathian = core.settings:get_flags("mgcarpathian_spflags"),
|
||||
valleys = core.settings:get_flags("mgvalleys_spflags"),
|
||||
flat = core.settings:get_flags("mgflat_spflags"),
|
||||
}
|
||||
local flags = dialogdata.flags
|
||||
|
||||
local gameidx = 0
|
||||
if gameid ~= nil then
|
||||
local _
|
||||
_, gameidx = pkgmgr.find_by_gameid(gameid)
|
||||
|
||||
if gameidx == nil then
|
||||
gameidx = 0
|
||||
end
|
||||
local game, gameidx = pkgmgr.find_by_gameid(gameid)
|
||||
if game == nil and hide_gamelist then
|
||||
-- should never happen but just pick the first game
|
||||
game = pkgmgr.get_game(1)
|
||||
gameidx = 1
|
||||
core.settings:set("menu_last_game", game.id)
|
||||
elseif game == nil then
|
||||
gameidx = 0
|
||||
end
|
||||
|
||||
local game_by_gameidx = core.get_game(gameidx)
|
||||
local disallowed_mapgen_settings = {}
|
||||
if game_by_gameidx ~= nil then
|
||||
local gamepath = game_by_gameidx.path
|
||||
local gameconfig = Settings(gamepath.."/game.conf")
|
||||
if game ~= nil then
|
||||
local gameconfig = Settings(game.path.."/game.conf")
|
||||
|
||||
local allowed_mapgens = (gameconfig:get("allowed_mapgens") or ""):split()
|
||||
for key, value in pairs(allowed_mapgens) do
|
||||
|
@ -156,7 +143,7 @@ local function create_world_formspec(dialogdata)
|
|||
end
|
||||
end
|
||||
|
||||
if disallowed_mapgens then
|
||||
if #disallowed_mapgens > 0 then
|
||||
for i = #mapgens, 1, -1 do
|
||||
if table.indexof(disallowed_mapgens, mapgens[i]) > 0 then
|
||||
table.remove(mapgens, i)
|
||||
|
@ -172,23 +159,29 @@ local function create_world_formspec(dialogdata)
|
|||
|
||||
local mglist = ""
|
||||
local selindex
|
||||
local i = 1
|
||||
local first_mg
|
||||
for k,v in pairs(mapgens) do
|
||||
if not first_mg then
|
||||
first_mg = v
|
||||
do -- build the list of mapgens
|
||||
local i = 1
|
||||
local first_mg
|
||||
for k, v in pairs(mapgens) do
|
||||
if not first_mg then
|
||||
first_mg = v
|
||||
end
|
||||
if current_mg == v then
|
||||
selindex = i
|
||||
end
|
||||
i = i + 1
|
||||
mglist = mglist .. core.formspec_escape(v) .. ","
|
||||
end
|
||||
if current_mg == v then
|
||||
selindex = i
|
||||
if not selindex then
|
||||
selindex = 1
|
||||
current_mg = first_mg
|
||||
end
|
||||
i = i + 1
|
||||
mglist = mglist .. v .. ","
|
||||
mglist = mglist:sub(1, -2)
|
||||
end
|
||||
if not selindex then
|
||||
selindex = 1
|
||||
current_mg = first_mg
|
||||
end
|
||||
mglist = mglist:sub(1, -2)
|
||||
|
||||
-- The logic of the flag element IDs is as follows:
|
||||
-- "flag_main_foo-bar-baz" controls dialogdata.flags["main"]["foo_bar_baz"]
|
||||
-- see the buttonhandler for the implementation of this
|
||||
|
||||
local mg_main_flags = function(mapgen, y)
|
||||
if mapgen == "singlenode" then
|
||||
|
@ -198,11 +191,11 @@ local function create_world_formspec(dialogdata)
|
|||
return "", y
|
||||
end
|
||||
|
||||
local form = "checkbox[0," .. y .. ";flag_mg_caves;" ..
|
||||
local form = "checkbox[0," .. y .. ";flag_main_caves;" ..
|
||||
fgettext("Caves") .. ";"..strflag(flags.main, "caves").."]"
|
||||
y = y + 0.5
|
||||
|
||||
form = form .. "checkbox[0,"..y..";flag_mg_dungeons;" ..
|
||||
form = form .. "checkbox[0,"..y..";flag_main_dungeons;" ..
|
||||
fgettext("Dungeons") .. ";"..strflag(flags.main, "dungeons").."]"
|
||||
y = y + 0.5
|
||||
|
||||
|
@ -213,7 +206,7 @@ local function create_world_formspec(dialogdata)
|
|||
else
|
||||
d_tt = fgettext("Structures appearing on the terrain, typically trees and plants")
|
||||
end
|
||||
form = form .. "checkbox[0,"..y..";flag_mg_decorations;" ..
|
||||
form = form .. "checkbox[0,"..y..";flag_main_decorations;" ..
|
||||
d_name .. ";" ..
|
||||
strflag(flags.main, "decorations").."]" ..
|
||||
"tooltip[flag_mg_decorations;" ..
|
||||
|
@ -221,7 +214,7 @@ local function create_world_formspec(dialogdata)
|
|||
"]"
|
||||
y = y + 0.5
|
||||
|
||||
form = form .. "tooltip[flag_mg_caves;" ..
|
||||
form = form .. "tooltip[flag_main_caves;" ..
|
||||
fgettext("Network of tunnels and caves")
|
||||
.. "]"
|
||||
return form, y
|
||||
|
@ -235,13 +228,13 @@ local function create_world_formspec(dialogdata)
|
|||
return "", y
|
||||
end
|
||||
local form = ""
|
||||
for _,tab in pairs(flag_checkboxes[mapgen]) do
|
||||
local id = "flag_mg"..mapgen.."_"..tab[1]
|
||||
for _, tab in pairs(flag_checkboxes[mapgen]) do
|
||||
local id = "flag_"..mapgen.."_"..tab[1]:gsub("_", "-")
|
||||
form = form .. ("checkbox[0,%f;%s;%s;%s]"):
|
||||
format(y, id, tab[2], strflag(flags[mapgen], tab[3]))
|
||||
format(y, id, tab[2], strflag(flags[mapgen], tab[1]))
|
||||
|
||||
if tab[4] then
|
||||
form = form .. "tooltip["..id..";"..tab[4].."]"
|
||||
if tab[3] then
|
||||
form = form .. "tooltip["..id..";"..tab[3].."]"
|
||||
end
|
||||
y = y + 0.5
|
||||
end
|
||||
|
@ -277,16 +270,14 @@ local function create_world_formspec(dialogdata)
|
|||
|
||||
-- biomeblend
|
||||
y = y + 0.55
|
||||
form = form .. "checkbox[0,"..y..";flag_mgv6_biomeblend;" ..
|
||||
form = form .. "checkbox[0,"..y..";flag_v6_biomeblend;" ..
|
||||
fgettext("Biome blending") .. ";"..strflag(flags.v6, "biomeblend").."]" ..
|
||||
"tooltip[flag_mgv6_biomeblend;" ..
|
||||
"tooltip[flag_v6_biomeblend;" ..
|
||||
fgettext("Smooth transition between biomes") .. "]"
|
||||
|
||||
return form, y
|
||||
end
|
||||
|
||||
current_seed = core.formspec_escape(current_seed)
|
||||
|
||||
local y_start = 0.0
|
||||
local y = y_start
|
||||
local str_flags, str_spflags
|
||||
|
@ -323,21 +314,27 @@ local function create_world_formspec(dialogdata)
|
|||
"container[0,0]"..
|
||||
"field[0.3,0.6;6,0.5;te_world_name;" ..
|
||||
fgettext("World name") ..
|
||||
";" .. core.formspec_escape(worldname) .. "]" ..
|
||||
";" .. core.formspec_escape(dialogdata.worldname) .. "]" ..
|
||||
"set_focus[te_world_name;false]" ..
|
||||
|
||||
"field[0.3,1.7;6,0.5;te_seed;" ..
|
||||
fgettext("Seed") ..
|
||||
";".. current_seed .. "]" ..
|
||||
";".. core.formspec_escape(dialogdata.seed) .. "]" ..
|
||||
|
||||
"label[0,2;" .. fgettext("Mapgen") .. "]"..
|
||||
"dropdown[0,2.5;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
|
||||
"dropdown[0,2.5;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]"
|
||||
|
||||
"label[0,3.35;" .. fgettext("Game") .. "]"..
|
||||
"textlist[0,3.85;5.8,"..gamelist_height..";games;" ..
|
||||
pkgmgr.gamelist() .. ";" .. gameidx .. ";false]" ..
|
||||
"container[0,4.5]" ..
|
||||
devtest_only ..
|
||||
"container_end[]" ..
|
||||
if not hide_gamelist or devtest_only ~= "" then
|
||||
retval = retval ..
|
||||
"label[0,3.35;" .. fgettext("Game") .. "]"..
|
||||
"textlist[0,3.85;5.8,"..gamelist_height..";games;" ..
|
||||
pkgmgr.gamelist() .. ";" .. gameidx .. ";false]" ..
|
||||
"container[0,4.5]" ..
|
||||
devtest_only ..
|
||||
"container_end[]"
|
||||
end
|
||||
|
||||
retval = retval ..
|
||||
"container_end[]" ..
|
||||
|
||||
-- Right side
|
||||
|
@ -360,9 +357,20 @@ local function create_world_buttonhandler(this, fields)
|
|||
fields["key_enter"] then
|
||||
|
||||
local worldname = fields["te_world_name"]
|
||||
local gameindex = core.get_textlist_index("games")
|
||||
local game, gameindex
|
||||
if hide_gamelist then
|
||||
game, gameindex = pkgmgr.find_by_gameid(core.settings:get("menu_last_game"))
|
||||
else
|
||||
gameindex = core.get_textlist_index("games")
|
||||
game = pkgmgr.get_game(gameindex)
|
||||
end
|
||||
|
||||
if gameindex ~= nil then
|
||||
local message
|
||||
if game == nil then
|
||||
message = fgettext("No game selected")
|
||||
end
|
||||
|
||||
if message == nil then
|
||||
-- For unnamed worlds use the generated name 'world<number>',
|
||||
-- where the number increments: it is set to 1 larger than the largest
|
||||
-- generated name number found.
|
||||
|
@ -377,36 +385,48 @@ local function create_world_buttonhandler(this, fields)
|
|||
worldname = "world" .. worldnum_max + 1
|
||||
end
|
||||
|
||||
core.settings:set("fixed_map_seed", fields["te_seed"])
|
||||
|
||||
local message
|
||||
if not menudata.worldlist:uid_exists_raw(worldname) then
|
||||
core.settings:set("mg_name",fields["dd_mapgen"])
|
||||
message = core.create_world(worldname,gameindex)
|
||||
else
|
||||
if menudata.worldlist:uid_exists_raw(worldname) then
|
||||
message = fgettext("A world named \"$1\" already exists", worldname)
|
||||
end
|
||||
|
||||
if message ~= nil then
|
||||
gamedata.errormessage = message
|
||||
else
|
||||
core.settings:set("menu_last_game",pkgmgr.games[gameindex].id)
|
||||
if this.data.update_worldlist_filter then
|
||||
menudata.worldlist:set_filtercriteria(pkgmgr.games[gameindex].id)
|
||||
mm_game_theme.update("singleplayer", pkgmgr.games[gameindex].id)
|
||||
end
|
||||
menudata.worldlist:refresh()
|
||||
core.settings:set("mainmenu_last_selected_world",
|
||||
menudata.worldlist:raw_index_by_uid(worldname))
|
||||
end
|
||||
else
|
||||
gamedata.errormessage = fgettext("No game selected")
|
||||
end
|
||||
|
||||
if message == nil then
|
||||
this.data.seed = fields["te_seed"]
|
||||
this.data.mg = fields["dd_mapgen"]
|
||||
|
||||
-- actual names as used by engine
|
||||
local settings = {
|
||||
fixed_map_seed = this.data.seed,
|
||||
mg_name = this.data.mg,
|
||||
mg_flags = table_to_flags(this.data.flags.main),
|
||||
mgv5_spflags = table_to_flags(this.data.flags.v5),
|
||||
mgv6_spflags = table_to_flags(this.data.flags.v6),
|
||||
mgv7_spflags = table_to_flags(this.data.flags.v7),
|
||||
mgfractal_spflags = table_to_flags(this.data.flags.fractal),
|
||||
mgcarpathian_spflags = table_to_flags(this.data.flags.carpathian),
|
||||
mgvalleys_spflags = table_to_flags(this.data.flags.valleys),
|
||||
mgflat_spflags = table_to_flags(this.data.flags.flat),
|
||||
}
|
||||
message = core.create_world(worldname, gameindex, settings)
|
||||
end
|
||||
|
||||
if message == nil then
|
||||
core.settings:set("menu_last_game", game.id)
|
||||
if this.data.update_worldlist_filter then
|
||||
menudata.worldlist:set_filtercriteria(game.id)
|
||||
end
|
||||
menudata.worldlist:refresh()
|
||||
core.settings:set("mainmenu_last_selected_world",
|
||||
menudata.worldlist:raw_index_by_uid(worldname))
|
||||
end
|
||||
|
||||
gamedata.errormessage = message
|
||||
this:delete()
|
||||
return true
|
||||
end
|
||||
|
||||
worldname = fields.te_world_name
|
||||
this.data.worldname = fields["te_world_name"]
|
||||
this.data.seed = fields["te_seed"]
|
||||
|
||||
if fields["games"] then
|
||||
local gameindex = core.get_textlist_index("games")
|
||||
|
@ -417,22 +437,11 @@ local function create_world_buttonhandler(this, fields)
|
|||
for k,v in pairs(fields) do
|
||||
local split = string.split(k, "_", nil, 3)
|
||||
if split and split[1] == "flag" then
|
||||
local setting
|
||||
if split[2] == "mg" then
|
||||
setting = "mg_flags"
|
||||
else
|
||||
setting = split[2].."_spflags"
|
||||
end
|
||||
-- We replaced the underscore of flag names with a dash.
|
||||
local flag = string.gsub(split[3], "-", "_")
|
||||
local ftable = core.settings:get_flags(setting)
|
||||
if v == "true" then
|
||||
ftable[flag] = true
|
||||
else
|
||||
ftable[flag] = false
|
||||
end
|
||||
local flags = table_to_flags(ftable)
|
||||
core.settings:set(setting, flags)
|
||||
local ftable = this.data.flags[split[2]]
|
||||
assert(ftable)
|
||||
ftable[flag] = v == "true"
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -446,18 +455,16 @@ local function create_world_buttonhandler(this, fields)
|
|||
local entry = core.formspec_escape(fields["mgv6_biomes"])
|
||||
for b=1, #mgv6_biomes do
|
||||
if entry == mgv6_biomes[b][1] then
|
||||
local ftable = core.settings:get_flags("mgv6_spflags")
|
||||
local ftable = this.data.flags.v6
|
||||
ftable.jungles = mgv6_biomes[b][2].jungles
|
||||
ftable.snowbiomes = mgv6_biomes[b][2].snowbiomes
|
||||
local flags = table_to_flags(ftable)
|
||||
core.settings:set("mgv6_spflags", flags)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if fields["dd_mapgen"] then
|
||||
core.settings:set("mg_name", fields["dd_mapgen"])
|
||||
this.data.mg = fields["dd_mapgen"]
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -466,12 +473,27 @@ end
|
|||
|
||||
|
||||
function create_create_world_dlg(update_worldlistfilter)
|
||||
worldname = ""
|
||||
local retval = dialog_create("sp_create_world",
|
||||
create_world_formspec,
|
||||
create_world_buttonhandler,
|
||||
nil)
|
||||
retval.update_worldlist_filter = update_worldlistfilter
|
||||
retval.data = {
|
||||
update_worldlist_filter = update_worldlistfilter,
|
||||
worldname = "",
|
||||
-- settings the world is created with:
|
||||
seed = core.settings:get("fixed_map_seed") or "",
|
||||
mg = core.settings:get("mg_name"),
|
||||
flags = {
|
||||
main = core.settings:get_flags("mg_flags"),
|
||||
v5 = core.settings:get_flags("mgv5_spflags"),
|
||||
v6 = core.settings:get_flags("mgv6_spflags"),
|
||||
v7 = core.settings:get_flags("mgv7_spflags"),
|
||||
fractal = core.settings:get_flags("mgfractal_spflags"),
|
||||
carpathian = core.settings:get_flags("mgcarpathian_spflags"),
|
||||
valleys = core.settings:get_flags("mgvalleys_spflags"),
|
||||
flat = core.settings:get_flags("mgflat_spflags"),
|
||||
}
|
||||
}
|
||||
|
||||
return retval
|
||||
end
|
||||
|
|
|
@ -33,10 +33,30 @@ if enable_gamebar then
|
|||
return game
|
||||
end
|
||||
|
||||
-- Apply menu changes from given game
|
||||
function apply_game(game)
|
||||
core.set_topleft_text(game.name)
|
||||
core.settings:set("menu_last_game", game.id)
|
||||
menudata.worldlist:set_filtercriteria(game.id)
|
||||
|
||||
mm_game_theme.update("singleplayer", game) -- this refreshes the formspec
|
||||
|
||||
local index = filterlist.get_current_index(menudata.worldlist,
|
||||
tonumber(core.settings:get("mainmenu_last_selected_world")))
|
||||
if not index or index < 1 then
|
||||
local selected = core.get_textlist_index("sp_worlds")
|
||||
if selected ~= nil and selected < #menudata.worldlist:get_list() then
|
||||
index = selected
|
||||
else
|
||||
index = #menudata.worldlist:get_list()
|
||||
end
|
||||
end
|
||||
menu_worldmt_legacy(index)
|
||||
end
|
||||
|
||||
function singleplayer_refresh_gamebar()
|
||||
|
||||
local old_bar = ui.find_by_name("game_button_bar")
|
||||
|
||||
if old_bar ~= nil then
|
||||
old_bar:delete()
|
||||
end
|
||||
|
@ -51,26 +71,10 @@ if enable_gamebar then
|
|||
return true
|
||||
end
|
||||
|
||||
for key,value in pairs(fields) do
|
||||
for j=1,#pkgmgr.games,1 do
|
||||
if ("game_btnbar_" .. pkgmgr.games[j].id == key) then
|
||||
mm_game_theme.update("singleplayer", pkgmgr.games[j])
|
||||
core.set_topleft_text(pkgmgr.games[j].name)
|
||||
core.settings:set("menu_last_game",pkgmgr.games[j].id)
|
||||
menudata.worldlist:set_filtercriteria(pkgmgr.games[j].id)
|
||||
local index = filterlist.get_current_index(menudata.worldlist,
|
||||
tonumber(core.settings:get("mainmenu_last_selected_world")))
|
||||
if not index or index < 1 then
|
||||
local selected = core.get_textlist_index("sp_worlds")
|
||||
if selected ~= nil and selected < #menudata.worldlist:get_list() then
|
||||
index = selected
|
||||
else
|
||||
index = #menudata.worldlist:get_list()
|
||||
end
|
||||
end
|
||||
menu_worldmt_legacy(index)
|
||||
return true
|
||||
end
|
||||
for _, game in ipairs(pkgmgr.games) do
|
||||
if fields["game_btnbar_" .. game.id] then
|
||||
apply_game(game)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -79,25 +83,22 @@ if enable_gamebar then
|
|||
game_buttonbar_button_handler,
|
||||
{x=-0.3,y=5.9}, "horizontal", {x=12.4,y=1.15})
|
||||
|
||||
for i=1,#pkgmgr.games,1 do
|
||||
local btn_name = "game_btnbar_" .. pkgmgr.games[i].id
|
||||
for _, game in ipairs(pkgmgr.games) do
|
||||
local btn_name = "game_btnbar_" .. game.id
|
||||
|
||||
local image = nil
|
||||
local text = nil
|
||||
local tooltip = core.formspec_escape(pkgmgr.games[i].name)
|
||||
local tooltip = core.formspec_escape(game.name)
|
||||
|
||||
if pkgmgr.games[i].menuicon_path ~= nil and
|
||||
pkgmgr.games[i].menuicon_path ~= "" then
|
||||
image = core.formspec_escape(pkgmgr.games[i].menuicon_path)
|
||||
if (game.menuicon_path or "") ~= "" then
|
||||
image = core.formspec_escape(game.menuicon_path)
|
||||
else
|
||||
|
||||
local part1 = pkgmgr.games[i].id:sub(1,5)
|
||||
local part2 = pkgmgr.games[i].id:sub(6,10)
|
||||
local part3 = pkgmgr.games[i].id:sub(11)
|
||||
local part1 = game.id:sub(1,5)
|
||||
local part2 = game.id:sub(6,10)
|
||||
local part3 = game.id:sub(11)
|
||||
|
||||
text = part1 .. "\n" .. part2
|
||||
if part3 ~= nil and
|
||||
part3 ~= "" then
|
||||
if part3 ~= "" then
|
||||
text = text .. "\n" .. part3
|
||||
end
|
||||
end
|
||||
|
@ -147,8 +148,12 @@ local function get_formspec(tabview, name, tabdata)
|
|||
tonumber(core.settings:get("mainmenu_last_selected_world")))
|
||||
local list = menudata.worldlist:get_list()
|
||||
local world = list and index and list[index]
|
||||
local gameid = world and world.gameid
|
||||
local game = gameid and pkgmgr.find_by_gameid(gameid)
|
||||
local game
|
||||
if world then
|
||||
game = pkgmgr.find_by_gameid(world.gameid)
|
||||
else
|
||||
game = current_game()
|
||||
end
|
||||
local disabled_settings = get_disabled_settings(game)
|
||||
|
||||
local creative, damage, host = "", "", ""
|
||||
|
@ -182,7 +187,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||
damage ..
|
||||
host ..
|
||||
"textlist[3.9,0.4;7.9,3.45;sp_worlds;" ..
|
||||
menu_render_worldlist() ..
|
||||
menu_render_worldlist(not enable_gamebar) ..
|
||||
";" .. index .. "]"
|
||||
|
||||
if core.settings:get_bool("enable_server") and disabled_settings["enable_server"] == nil then
|
||||
|
@ -319,7 +324,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
|||
end
|
||||
|
||||
if fields["world_create"] ~= nil then
|
||||
local create_world_dlg = create_create_world_dlg(true)
|
||||
local create_world_dlg = create_create_world_dlg(enable_gamebar)
|
||||
create_world_dlg:set_parent(this)
|
||||
this:hide()
|
||||
create_world_dlg:show()
|
||||
|
@ -371,11 +376,8 @@ if enable_gamebar then
|
|||
function on_change(type, old_tab, new_tab)
|
||||
if (type == "ENTER") then
|
||||
local game = current_game()
|
||||
|
||||
if game then
|
||||
menudata.worldlist:set_filtercriteria(game.id)
|
||||
core.set_topleft_text(game.name)
|
||||
mm_game_theme.update("singleplayer",game)
|
||||
apply_game(game)
|
||||
end
|
||||
|
||||
singleplayer_refresh_gamebar()
|
||||
|
|
|
@ -886,10 +886,6 @@ tooltip_show_delay (Tooltip delay) int 400
|
|||
# Append item name to tooltip.
|
||||
tooltip_append_itemname (Append item name) bool false
|
||||
|
||||
# Whether FreeType fonts are used, requires FreeType support to be compiled in.
|
||||
# If disabled, bitmap and XML vectors fonts are used instead.
|
||||
freetype (FreeType fonts) bool true
|
||||
|
||||
font_bold (Font bold by default) bool false
|
||||
|
||||
font_italic (Font italic by default) bool false
|
||||
|
@ -909,9 +905,7 @@ font_size (Font size) int 16 1
|
|||
# sized 16, 32, 48, etc., so a mod requesting a size of 25 will get 32.
|
||||
font_size_divisible_by (Font size divisible by) int 1 1
|
||||
|
||||
# Path to the default font.
|
||||
# If “freetype” setting is enabled: Must be a TrueType font.
|
||||
# If “freetype” setting is disabled: Must be a bitmap or XML vectors font.
|
||||
# Path to the default font. Must be a TrueType font.
|
||||
# The fallback font will be used if the font cannot be loaded.
|
||||
font_path (Regular font path) filepath fonts/Arimo-Regular.ttf
|
||||
|
||||
|
@ -928,9 +922,7 @@ mono_font_size (Monospace font size) int 16 1
|
|||
# sized 16, 32, 48, etc., so a mod requesting a size of 25 will get 32.
|
||||
mono_font_size_divisible_by (Monospace font size divisible by) int 1 1
|
||||
|
||||
# Path to the monospace font.
|
||||
# If “freetype” setting is enabled: Must be a TrueType font.
|
||||
# If “freetype” setting is disabled: Must be a bitmap or XML vectors font.
|
||||
# Path to the monospace font. Must be a TrueType font.
|
||||
# This font is used for e.g. the console and profiler screen.
|
||||
mono_font_path (Monospace font path) filepath fonts/Cousine-Regular.ttf
|
||||
|
||||
|
@ -938,9 +930,7 @@ mono_font_path_bold (Bold monospace font path) filepath fonts/Cousine-Bold.ttf
|
|||
mono_font_path_italic (Italic monospace font path) filepath fonts/Cousine-Italic.ttf
|
||||
mono_font_path_bold_italic (Bold and italic monospace font path) filepath fonts/Cousine-BoldItalic.ttf
|
||||
|
||||
# Path of the fallback font.
|
||||
# If “freetype” setting is enabled: Must be a TrueType font.
|
||||
# If “freetype” setting is disabled: Must be a bitmap or XML vectors font.
|
||||
# Path of the fallback font. Must be a TrueType font.
|
||||
# This font will be used for certain languages or if the default font is unavailable.
|
||||
fallback_font_path (Fallback font path) filepath fonts/DroidSansFallbackFull.ttf
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ PREDEFINED = "USE_SPATIAL=1" \
|
|||
"USE_REDIS=1" \
|
||||
"USE_SOUND=1" \
|
||||
"USE_CURL=1" \
|
||||
"USE_FREETYPE=1" \
|
||||
"USE_GETTEXT=1"
|
||||
|
||||
# Input
|
||||
|
|
Before Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 119 KiB |
Before Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 149 KiB |
Before Width: | Height: | Size: 166 KiB |
Before Width: | Height: | Size: 186 KiB |
Before Width: | Height: | Size: 196 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 50 KiB |
|
@ -1014,6 +1014,9 @@
|
|||
# When gui_scaling_filter is true, all GUI images need to be
|
||||
# filtered in software, but some images are generated directly
|
||||
# to hardware (e.g. render-to-texture for nodes in inventory).
|
||||
# This will smooth over some of the rough edges, and blend
|
||||
# pixels when scaling down, at the cost of blurring some
|
||||
# edge pixels when images are scaled by non-integer sizes.
|
||||
# type: bool
|
||||
# gui_scaling_filter = false
|
||||
|
||||
|
|
|
@ -122,16 +122,8 @@ if(BUILD_CLIENT)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
option(ENABLE_FREETYPE "Enable FreeType2 (TrueType fonts and basic unicode support)" TRUE)
|
||||
set(USE_FREETYPE FALSE)
|
||||
|
||||
if(BUILD_CLIENT AND ENABLE_FREETYPE)
|
||||
find_package(Freetype)
|
||||
if(FREETYPE_FOUND)
|
||||
message(STATUS "Freetype enabled.")
|
||||
set(USE_FREETYPE TRUE)
|
||||
endif()
|
||||
if(BUILD_CLIENT)
|
||||
find_package(Freetype REQUIRED)
|
||||
endif()
|
||||
|
||||
option(ENABLE_CURSES "Enable ncurses console" TRUE)
|
||||
|
@ -495,13 +487,11 @@ include_directories(
|
|||
${PROJECT_SOURCE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${ZSTD_INCLUDE_DIR}
|
||||
${SOUND_INCLUDE_DIRS}
|
||||
${SQLITE3_INCLUDE_DIR}
|
||||
${LUA_INCLUDE_DIR}
|
||||
${GMP_INCLUDE_DIR}
|
||||
${JSON_INCLUDE_DIR}
|
||||
${LUA_BIT_INCLUDE_DIR}
|
||||
${X11_INCLUDE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/script
|
||||
)
|
||||
|
||||
|
@ -509,8 +499,12 @@ if(USE_GETTEXT)
|
|||
include_directories(${GETTEXT_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
if(USE_FREETYPE)
|
||||
include_directories(${FREETYPE_INCLUDE_DIRS})
|
||||
if(BUILD_CLIENT)
|
||||
include_directories(
|
||||
${FREETYPE_INCLUDE_DIRS}
|
||||
${SOUND_INCLUDE_DIRS}
|
||||
${X11_INCLUDE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(USE_CURL)
|
||||
|
@ -539,6 +533,7 @@ if(BUILD_CLIENT)
|
|||
${GMP_LIBRARY}
|
||||
${JSON_LIBRARY}
|
||||
${LUA_BIT_LIBRARY}
|
||||
${FREETYPE_LIBRARY}
|
||||
${PLATFORM_LIBS}
|
||||
)
|
||||
if(NOT USE_LUAJIT)
|
||||
|
@ -573,17 +568,11 @@ if(BUILD_CLIENT)
|
|||
${CURL_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
if(USE_FREETYPE)
|
||||
if(FREETYPE_PKGCONFIG_FOUND)
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${FREETYPE_CFLAGS_STR}"
|
||||
)
|
||||
endif()
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
${FREETYPE_LIBRARY}
|
||||
)
|
||||
if(FREETYPE_PKGCONFIG_FOUND)
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${FREETYPE_CFLAGS_STR}"
|
||||
)
|
||||
endif()
|
||||
if (USE_CURSES)
|
||||
target_link_libraries(${PROJECT_NAME} ${CURSES_LIBRARIES})
|
||||
|
@ -896,14 +885,8 @@ if(BUILD_CLIENT)
|
|||
endforeach()
|
||||
endif()
|
||||
|
||||
# Install necessary fonts depending on configuration
|
||||
if(USE_FREETYPE)
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
|
||||
FILES_MATCHING PATTERN "*.ttf" PATTERN "*.txt")
|
||||
else()
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
|
||||
FILES_MATCHING PATTERN "*.png" PATTERN "*.xml")
|
||||
endif()
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
|
||||
FILES_MATCHING PATTERN "*.ttf" PATTERN "*.txt")
|
||||
endif(BUILD_CLIENT)
|
||||
|
||||
if(BUILD_SERVER)
|
||||
|
|
|
@ -931,7 +931,7 @@ void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket *
|
|||
v3f sf = myplayer->getSpeed() * 100;
|
||||
s32 pitch = myplayer->getPitch() * 100;
|
||||
s32 yaw = myplayer->getYaw() * 100;
|
||||
u32 keyPressed = myplayer->keyPressed;
|
||||
u32 keyPressed = myplayer->control.getKeysPressed();
|
||||
// scaled by 80, so that pi can fit into a u8
|
||||
u8 fov = clientMap->getCameraFov() * 80;
|
||||
u8 wanted_range = MYMIN(255,
|
||||
|
@ -1287,22 +1287,24 @@ void Client::sendPlayerPos()
|
|||
if (!player)
|
||||
return;
|
||||
|
||||
ClientMap &map = m_env.getClientMap();
|
||||
u8 camera_fov = map.getCameraFov();
|
||||
u8 wanted_range = map.getControl().wanted_range;
|
||||
|
||||
// Save bandwidth by only updating position when
|
||||
// player is not dead and something changed
|
||||
|
||||
if (m_activeobjects_received && player->isDead())
|
||||
return;
|
||||
|
||||
ClientMap &map = m_env.getClientMap();
|
||||
u8 camera_fov = map.getCameraFov();
|
||||
u8 wanted_range = map.getControl().wanted_range;
|
||||
|
||||
u32 keyPressed = player->control.getKeysPressed();
|
||||
|
||||
if (
|
||||
player->last_position == player->getPosition() &&
|
||||
player->last_speed == player->getSpeed() &&
|
||||
player->last_pitch == player->getPitch() &&
|
||||
player->last_yaw == player->getYaw() &&
|
||||
player->last_keyPressed == player->keyPressed &&
|
||||
player->last_keyPressed == keyPressed &&
|
||||
player->last_camera_fov == camera_fov &&
|
||||
player->last_wanted_range == wanted_range)
|
||||
return;
|
||||
|
@ -1311,7 +1313,7 @@ void Client::sendPlayerPos()
|
|||
player->last_speed = player->getSpeed();
|
||||
player->last_pitch = player->getPitch();
|
||||
player->last_yaw = player->getYaw();
|
||||
player->last_keyPressed = player->keyPressed;
|
||||
player->last_keyPressed = keyPressed;
|
||||
player->last_camera_fov = camera_fov;
|
||||
player->last_wanted_range = wanted_range;
|
||||
|
||||
|
|
|
@ -70,10 +70,10 @@ static void dump_start_data(const GameStartData &data)
|
|||
|
||||
ClientLauncher::~ClientLauncher()
|
||||
{
|
||||
delete receiver;
|
||||
|
||||
delete input;
|
||||
|
||||
delete receiver;
|
||||
|
||||
delete g_fontengine;
|
||||
delete g_gamecallback;
|
||||
|
||||
|
|
|
@ -24,10 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "porting.h"
|
||||
#include "filesys.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#if USE_FREETYPE
|
||||
#include "irrlicht_changes/CGUITTFont.h"
|
||||
#endif
|
||||
|
||||
/** maximum size distance for getting a "similar" font size */
|
||||
#define MAX_FONT_SIZE_OFFSET 10
|
||||
|
@ -45,9 +42,8 @@ static void font_setting_changed(const std::string &name, void *userdata)
|
|||
FontEngine::FontEngine(gui::IGUIEnvironment* env) :
|
||||
m_env(env)
|
||||
{
|
||||
|
||||
for (u32 &i : m_default_size) {
|
||||
i = (FontMode) FONT_SIZE_UNSPECIFIED;
|
||||
i = FONT_SIZE_UNSPECIFIED;
|
||||
}
|
||||
|
||||
assert(g_settings != NULL); // pre-condition
|
||||
|
@ -56,25 +52,19 @@ FontEngine::FontEngine(gui::IGUIEnvironment* env) :
|
|||
|
||||
readSettings();
|
||||
|
||||
if (m_currentMode != FM_Simple) {
|
||||
g_settings->registerChangedCallback("font_size", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("font_bold", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("font_italic", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("font_path", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("font_path_bold", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("font_path_italic", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("font_path_bolditalic", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("font_shadow", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("font_shadow_alpha", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("font_size_divisible_by", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("fallback_font_path", font_setting_changed, NULL);
|
||||
}
|
||||
const char *settings[] = {
|
||||
"font_size", "font_bold", "font_italic", "font_size_divisible_by",
|
||||
"mono_font_size", "mono_font_size_divisible_by",
|
||||
"font_shadow", "font_shadow_alpha",
|
||||
"font_path", "font_path_bold", "font_path_italic", "font_path_bold_italic",
|
||||
"mono_font_path", "mono_font_path_bold", "mono_font_path_italic",
|
||||
"mono_font_path_bold_italic",
|
||||
"fallback_font_path",
|
||||
"screen_dpi", "gui_scaling",
|
||||
};
|
||||
|
||||
g_settings->registerChangedCallback("mono_font_path", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("mono_font_size", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("mono_font_size_divisible_by", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("screen_dpi", font_setting_changed, NULL);
|
||||
g_settings->registerChangedCallback("gui_scaling", font_setting_changed, NULL);
|
||||
for (auto name : settings)
|
||||
g_settings->registerChangedCallback(name, font_setting_changed, NULL);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -108,16 +98,8 @@ irr::gui::IGUIFont *FontEngine::getFont(FontSpec spec, bool may_fail)
|
|||
{
|
||||
if (spec.mode == FM_Unspecified) {
|
||||
spec.mode = m_currentMode;
|
||||
} else if (m_currentMode == FM_Simple) {
|
||||
// Freetype disabled -> Force simple mode
|
||||
spec.mode = (spec.mode == FM_Mono ||
|
||||
spec.mode == FM_SimpleMono) ?
|
||||
FM_SimpleMono : FM_Simple;
|
||||
// Support for those could be added, but who cares?
|
||||
spec.bold = false;
|
||||
spec.italic = false;
|
||||
} else if (spec.mode == _FM_Fallback) {
|
||||
// Fallback font doesn't support these either
|
||||
// Fallback font doesn't support these
|
||||
spec.bold = false;
|
||||
spec.italic = false;
|
||||
}
|
||||
|
@ -134,11 +116,7 @@ irr::gui::IGUIFont *FontEngine::getFont(FontSpec spec, bool may_fail)
|
|||
return it->second;
|
||||
|
||||
// Font does not yet exist
|
||||
gui::IGUIFont *font = nullptr;
|
||||
if (spec.mode == FM_Simple || spec.mode == FM_SimpleMono)
|
||||
font = initSimpleFont(spec);
|
||||
else
|
||||
font = initFont(spec);
|
||||
gui::IGUIFont *font = initFont(spec);
|
||||
|
||||
if (!font && !may_fail) {
|
||||
errorstream << "Minetest cannot continue without a valid font. "
|
||||
|
@ -185,13 +163,6 @@ unsigned int FontEngine::getDefaultFontSize()
|
|||
|
||||
unsigned int FontEngine::getFontSize(FontMode mode)
|
||||
{
|
||||
if (m_currentMode == FM_Simple) {
|
||||
if (mode == FM_Mono || mode == FM_SimpleMono)
|
||||
return m_default_size[FM_SimpleMono];
|
||||
else
|
||||
return m_default_size[FM_Simple];
|
||||
}
|
||||
|
||||
if (mode == FM_Unspecified)
|
||||
return m_default_size[FM_Standard];
|
||||
|
||||
|
@ -201,20 +172,12 @@ unsigned int FontEngine::getFontSize(FontMode mode)
|
|||
/******************************************************************************/
|
||||
void FontEngine::readSettings()
|
||||
{
|
||||
if (USE_FREETYPE && g_settings->getBool("freetype")) {
|
||||
m_default_size[FM_Standard] = g_settings->getU16("font_size");
|
||||
m_default_size[_FM_Fallback] = g_settings->getU16("font_size");
|
||||
m_default_size[FM_Mono] = g_settings->getU16("mono_font_size");
|
||||
m_default_size[FM_Standard] = g_settings->getU16("font_size");
|
||||
m_default_size[_FM_Fallback] = g_settings->getU16("font_size");
|
||||
m_default_size[FM_Mono] = g_settings->getU16("mono_font_size");
|
||||
|
||||
m_default_bold = g_settings->getBool("font_bold");
|
||||
m_default_italic = g_settings->getBool("font_italic");
|
||||
|
||||
} else {
|
||||
m_currentMode = FM_Simple;
|
||||
}
|
||||
|
||||
m_default_size[FM_Simple] = g_settings->getU16("font_size");
|
||||
m_default_size[FM_SimpleMono] = g_settings->getU16("mono_font_size");
|
||||
m_default_bold = g_settings->getBool("font_bold");
|
||||
m_default_italic = g_settings->getBool("font_italic");
|
||||
|
||||
cleanCache();
|
||||
updateFontCache();
|
||||
|
@ -283,7 +246,6 @@ gui::IGUIFont *FontEngine::initFont(const FontSpec &spec)
|
|||
Settings::getLayer(SL_DEFAULTS)->get(path_setting)
|
||||
};
|
||||
|
||||
#if USE_FREETYPE
|
||||
for (const std::string &font_path : fallback_settings) {
|
||||
gui::CGUITTFont *font = gui::CGUITTFont::createTTFont(m_env,
|
||||
font_path.c_str(), size, true, true, font_shadow,
|
||||
|
@ -302,80 +264,5 @@ gui::IGUIFont *FontEngine::initFont(const FontSpec &spec)
|
|||
}
|
||||
return font;
|
||||
}
|
||||
#else
|
||||
errorstream << "FontEngine: Tried to load TTF font but Minetest was"
|
||||
" compiled without Freetype." << std::endl;
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** initialize a font without freetype */
|
||||
gui::IGUIFont *FontEngine::initSimpleFont(const FontSpec &spec)
|
||||
{
|
||||
assert(spec.mode == FM_Simple || spec.mode == FM_SimpleMono);
|
||||
assert(spec.size != FONT_SIZE_UNSPECIFIED);
|
||||
|
||||
const std::string &font_path = g_settings->get(
|
||||
(spec.mode == FM_SimpleMono) ? "mono_font_path" : "font_path");
|
||||
|
||||
size_t pos_dot = font_path.find_last_of('.');
|
||||
std::string basename = font_path, ending;
|
||||
if (pos_dot != std::string::npos)
|
||||
ending = lowercase(font_path.substr(pos_dot));
|
||||
|
||||
if (ending == ".ttf") {
|
||||
errorstream << "FontEngine: Found font \"" << font_path
|
||||
<< "\" but freetype is not available." << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (ending == ".xml" || ending == ".png")
|
||||
basename = font_path.substr(0, pos_dot);
|
||||
|
||||
u32 size = std::floor(
|
||||
RenderingEngine::getDisplayDensity() *
|
||||
g_settings->getFloat("gui_scaling") *
|
||||
spec.size);
|
||||
|
||||
irr::gui::IGUIFont *font = nullptr;
|
||||
std::string font_extensions[] = { ".png", ".xml" };
|
||||
|
||||
// Find nearest matching font scale
|
||||
// Does a "zig-zag motion" (positibe/negative), from 0 to MAX_FONT_SIZE_OFFSET
|
||||
for (s32 zoffset = 0; zoffset < MAX_FONT_SIZE_OFFSET * 2; zoffset++) {
|
||||
std::stringstream path;
|
||||
|
||||
// LSB to sign
|
||||
s32 sign = (zoffset & 1) ? -1 : 1;
|
||||
s32 offset = zoffset >> 1;
|
||||
|
||||
for (const std::string &ext : font_extensions) {
|
||||
path.str(""); // Clear
|
||||
path << basename << "_" << (size + offset * sign) << ext;
|
||||
|
||||
if (!fs::PathExists(path.str()))
|
||||
continue;
|
||||
|
||||
font = m_env->getFont(path.str().c_str());
|
||||
|
||||
if (font) {
|
||||
verbosestream << "FontEngine: found font: " << path.str() << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (font)
|
||||
break;
|
||||
}
|
||||
|
||||
// try name direct
|
||||
if (font == NULL) {
|
||||
if (fs::PathExists(font_path)) {
|
||||
font = m_env->getFont(font_path.c_str());
|
||||
if (font)
|
||||
verbosestream << "FontEngine: found font: " << font_path << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@ enum FontMode : u8 {
|
|||
FM_Standard = 0,
|
||||
FM_Mono,
|
||||
_FM_Fallback, // do not use directly
|
||||
FM_Simple,
|
||||
FM_SimpleMono,
|
||||
FM_MaxMode,
|
||||
FM_Unspecified
|
||||
};
|
||||
|
@ -140,9 +138,6 @@ private:
|
|||
/** initialize a new TTF font */
|
||||
gui::IGUIFont *initFont(const FontSpec &spec);
|
||||
|
||||
/** initialize a font without freetype */
|
||||
gui::IGUIFont *initSimpleFont(const FontSpec &spec);
|
||||
|
||||
/** update current minetest skin with font changes */
|
||||
void updateSkin();
|
||||
|
||||
|
@ -165,8 +160,8 @@ private:
|
|||
bool m_default_bold = false;
|
||||
bool m_default_italic = false;
|
||||
|
||||
/** current font engine mode */
|
||||
FontMode m_currentMode = FM_Standard;
|
||||
/** default font engine mode (fixed) */
|
||||
static const FontMode m_currentMode = FM_Standard;
|
||||
|
||||
DISABLE_CLASS_COPY(FontEngine);
|
||||
};
|
||||
|
|
|
@ -2481,6 +2481,10 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
|
|||
//TimeTaker tt("update player control", NULL, PRECISION_NANO);
|
||||
|
||||
PlayerControl control(
|
||||
isKeyDown(KeyType::FORWARD),
|
||||
isKeyDown(KeyType::BACKWARD),
|
||||
isKeyDown(KeyType::LEFT),
|
||||
isKeyDown(KeyType::RIGHT),
|
||||
isKeyDown(KeyType::JUMP) || player->getAutojump(),
|
||||
isKeyDown(KeyType::AUX1),
|
||||
isKeyDown(KeyType::SNEAK),
|
||||
|
@ -2511,39 +2515,7 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
|
|||
}
|
||||
#endif
|
||||
|
||||
u32 keypress_bits = (
|
||||
( (u32)(control.jump & 0x1) << 4) |
|
||||
( (u32)(control.aux1 & 0x1) << 5) |
|
||||
( (u32)(control.sneak & 0x1) << 6) |
|
||||
( (u32)(control.dig & 0x1) << 7) |
|
||||
( (u32)(control.place & 0x1) << 8) |
|
||||
( (u32)(control.zoom & 0x1) << 9)
|
||||
);
|
||||
|
||||
// Set direction keys to ensure mod compatibility
|
||||
if (control.movement_speed > 0.001f) {
|
||||
float absolute_direction;
|
||||
|
||||
// Check in original orientation (absolute value indicates forward / backward)
|
||||
absolute_direction = abs(control.movement_direction);
|
||||
if (absolute_direction < (3.0f / 8.0f * M_PI))
|
||||
keypress_bits |= (u32)(0x1 << 0); // Forward
|
||||
if (absolute_direction > (5.0f / 8.0f * M_PI))
|
||||
keypress_bits |= (u32)(0x1 << 1); // Backward
|
||||
|
||||
// Rotate entire coordinate system by 90 degrees (absolute value indicates left / right)
|
||||
absolute_direction = control.movement_direction + M_PI_2;
|
||||
if (absolute_direction >= M_PI)
|
||||
absolute_direction -= 2 * M_PI;
|
||||
absolute_direction = abs(absolute_direction);
|
||||
if (absolute_direction < (3.0f / 8.0f * M_PI))
|
||||
keypress_bits |= (u32)(0x1 << 2); // Left
|
||||
if (absolute_direction > (5.0f / 8.0f * M_PI))
|
||||
keypress_bits |= (u32)(0x1 << 3); // Right
|
||||
}
|
||||
|
||||
client->setPlayerControl(control);
|
||||
player->keyPressed = keypress_bits;
|
||||
|
||||
//tt.stop();
|
||||
}
|
||||
|
|
|
@ -152,8 +152,14 @@ public:
|
|||
// in the subsequent iteration of Game::processPlayerInteraction
|
||||
bool WasKeyReleased(const KeyPress &keycode) const { return keyWasReleased[keycode]; }
|
||||
|
||||
void listenForKey(const KeyPress &keyCode) { keysListenedFor.set(keyCode); }
|
||||
void dontListenForKeys() { keysListenedFor.clear(); }
|
||||
void listenForKey(const KeyPress &keyCode)
|
||||
{
|
||||
keysListenedFor.set(keyCode);
|
||||
}
|
||||
void dontListenForKeys()
|
||||
{
|
||||
keysListenedFor.clear();
|
||||
}
|
||||
|
||||
s32 getMouseWheel()
|
||||
{
|
||||
|
@ -189,8 +195,6 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
s32 mouse_wheel = 0;
|
||||
|
||||
JoystickController *joystick = nullptr;
|
||||
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
|
@ -198,6 +202,8 @@ public:
|
|||
#endif
|
||||
|
||||
private:
|
||||
s32 mouse_wheel = 0;
|
||||
|
||||
// The current state of keys
|
||||
KeyList keyIsDown;
|
||||
|
||||
|
@ -272,6 +278,12 @@ public:
|
|||
{
|
||||
m_receiver->joystick = &joystick;
|
||||
}
|
||||
|
||||
virtual ~RealInputHandler()
|
||||
{
|
||||
m_receiver->joystick = nullptr;
|
||||
}
|
||||
|
||||
virtual bool isKeyDown(GameKeyType k)
|
||||
{
|
||||
return m_receiver->IsKeyDown(keycache.key[k]) || joystick.isKeyDown(k);
|
||||
|
@ -288,6 +300,7 @@ public:
|
|||
{
|
||||
return m_receiver->WasKeyReleased(keycache.key[k]) || joystick.wasKeyReleased(k);
|
||||
}
|
||||
|
||||
virtual float getMovementSpeed()
|
||||
{
|
||||
bool f = m_receiver->IsKeyDown(keycache.key[KeyType::FORWARD]),
|
||||
|
@ -307,6 +320,7 @@ public:
|
|||
}
|
||||
return joystick.getMovementSpeed();
|
||||
}
|
||||
|
||||
virtual float getMovementDirection()
|
||||
{
|
||||
float x = 0, z = 0;
|
||||
|
@ -326,10 +340,12 @@ public:
|
|||
else
|
||||
return joystick.getMovementDirection();
|
||||
}
|
||||
|
||||
virtual bool cancelPressed()
|
||||
{
|
||||
return wasKeyDown(KeyType::ESC) || m_receiver->WasKeyDown(CancelKey);
|
||||
}
|
||||
|
||||
virtual void clearWasKeyPressed()
|
||||
{
|
||||
m_receiver->clearWasKeyPressed();
|
||||
|
@ -338,17 +354,21 @@ public:
|
|||
{
|
||||
m_receiver->clearWasKeyReleased();
|
||||
}
|
||||
|
||||
virtual void listenForKey(const KeyPress &keyCode)
|
||||
{
|
||||
m_receiver->listenForKey(keyCode);
|
||||
}
|
||||
virtual void dontListenForKeys() { m_receiver->dontListenForKeys(); }
|
||||
virtual void dontListenForKeys()
|
||||
{
|
||||
m_receiver->dontListenForKeys();
|
||||
}
|
||||
|
||||
virtual v2s32 getMousePos()
|
||||
{
|
||||
if (RenderingEngine::get_raw_device()->getCursorControl()) {
|
||||
return RenderingEngine::get_raw_device()
|
||||
->getCursorControl()
|
||||
->getPosition();
|
||||
auto control = RenderingEngine::get_raw_device()->getCursorControl();
|
||||
if (control) {
|
||||
return control->getPosition();
|
||||
}
|
||||
|
||||
return m_mousepos;
|
||||
|
@ -356,16 +376,18 @@ public:
|
|||
|
||||
virtual void setMousePos(s32 x, s32 y)
|
||||
{
|
||||
if (RenderingEngine::get_raw_device()->getCursorControl()) {
|
||||
RenderingEngine::get_raw_device()
|
||||
->getCursorControl()
|
||||
->setPosition(x, y);
|
||||
auto control = RenderingEngine::get_raw_device()->getCursorControl();
|
||||
if (control) {
|
||||
control->setPosition(x, y);
|
||||
} else {
|
||||
m_mousepos = v2s32(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
virtual s32 getMouseWheel() { return m_receiver->getMouseWheel(); }
|
||||
virtual s32 getMouseWheel()
|
||||
{
|
||||
return m_receiver->getMouseWheel();
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
|
|
|
@ -1096,10 +1096,8 @@ void LocalPlayer::handleAutojump(f32 dtime, Environment *env,
|
|||
if (m_autojump)
|
||||
return;
|
||||
|
||||
bool control_forward = keyPressed & (1 << 0);
|
||||
|
||||
bool could_autojump =
|
||||
m_can_jump && !control.jump && !control.sneak && control_forward;
|
||||
m_can_jump && !control.jump && !control.sneak && control.isMoving();
|
||||
|
||||
if (!could_autojump)
|
||||
return;
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
v3f last_speed;
|
||||
float last_pitch = 0.0f;
|
||||
float last_yaw = 0.0f;
|
||||
unsigned int last_keyPressed = 0;
|
||||
u32 last_keyPressed = 0;
|
||||
u8 last_camera_fov = 0;
|
||||
u8 last_wanted_range = 0;
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#cmakedefine01 USE_GETTEXT
|
||||
#cmakedefine01 USE_CURL
|
||||
#cmakedefine01 USE_SOUND
|
||||
#cmakedefine01 USE_FREETYPE
|
||||
#cmakedefine01 USE_CURSES
|
||||
#cmakedefine01 USE_LEVELDB
|
||||
#cmakedefine01 USE_LUAJIT
|
||||
|
|
|
@ -111,4 +111,3 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
*/
|
||||
|
||||
#define TTF_DEFAULT_FONT_SIZE (16)
|
||||
#define DEFAULT_FONT_SIZE (10)
|
||||
|
|
|
@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "log.h"
|
||||
#include "util/strfnd.h"
|
||||
#include "defaultsettings.h" // for set_default_settings
|
||||
#include "mapgen/mapgen.h" // for MapgenParams
|
||||
#include "map_settings_manager.h"
|
||||
#include "util/string.h"
|
||||
|
||||
#ifndef SERVER
|
||||
|
@ -370,19 +370,12 @@ void loadGameConfAndInitWorld(const std::string &path, const std::string &name,
|
|||
// Create map_meta.txt if does not already exist
|
||||
std::string map_meta_path = final_path + DIR_DELIM + "map_meta.txt";
|
||||
if (!fs::PathExists(map_meta_path)) {
|
||||
verbosestream << "Creating map_meta.txt (" << map_meta_path << ")"
|
||||
<< std::endl;
|
||||
std::ostringstream oss(std::ios_base::binary);
|
||||
MapSettingsManager mgr(map_meta_path);
|
||||
|
||||
Settings conf;
|
||||
MapgenParams params;
|
||||
mgr.setMapSetting("seed", g_settings->get("fixed_map_seed"));
|
||||
|
||||
params.readParams(g_settings);
|
||||
params.writeParams(&conf);
|
||||
conf.writeLines(oss);
|
||||
oss << "[end_of_params]\n";
|
||||
|
||||
fs::safeWriteToFile(map_meta_path, oss.str());
|
||||
mgr.makeMapgenParams();
|
||||
mgr.saveMapMeta();
|
||||
}
|
||||
|
||||
// The Settings object is no longer needed for created worlds
|
||||
|
|
|
@ -303,8 +303,7 @@ void set_default_settings()
|
|||
settings->setDefault("main_menu_path", "");
|
||||
settings->setDefault("serverlist_file", "favoriteservers.json");
|
||||
|
||||
#if USE_FREETYPE
|
||||
settings->setDefault("freetype", "true");
|
||||
// General font settings
|
||||
settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "Arimo-Regular.ttf"));
|
||||
settings->setDefault("font_path_italic", porting::getDataPath("fonts" DIR_DELIM "Arimo-Italic.ttf"));
|
||||
settings->setDefault("font_path_bold", porting::getDataPath("fonts" DIR_DELIM "Arimo-Bold.ttf"));
|
||||
|
@ -322,14 +321,6 @@ void set_default_settings()
|
|||
settings->setDefault("fallback_font_path", porting::getDataPath("fonts" DIR_DELIM "DroidSansFallbackFull.ttf"));
|
||||
|
||||
std::string font_size_str = std::to_string(TTF_DEFAULT_FONT_SIZE);
|
||||
#else
|
||||
settings->setDefault("freetype", "false");
|
||||
settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "mono_dejavu_sans"));
|
||||
settings->setDefault("mono_font_path", porting::getDataPath("fonts" DIR_DELIM "mono_dejavu_sans"));
|
||||
|
||||
std::string font_size_str = std::to_string(DEFAULT_FONT_SIZE);
|
||||
#endif
|
||||
// General font settings
|
||||
settings->setDefault("font_size", font_size_str);
|
||||
settings->setDefault("mono_font_size", font_size_str);
|
||||
settings->setDefault("chat_font_size", "0"); // Default "font_size"
|
||||
|
|
|
@ -30,12 +30,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "client/fontengine.h"
|
||||
#include "log.h"
|
||||
#include "gettext.h"
|
||||
#include "irrlicht_changes/CGUITTFont.h"
|
||||
#include <string>
|
||||
|
||||
#if USE_FREETYPE
|
||||
#include "irrlicht_changes/CGUITTFont.h"
|
||||
#endif
|
||||
|
||||
inline u32 clamp_u8(s32 value)
|
||||
{
|
||||
return (u32) MYMIN(MYMAX(value, 0), 255);
|
||||
|
@ -328,19 +325,16 @@ void GUIChatConsole::drawText()
|
|||
core::rect<s32> destrect(
|
||||
x, y, x + m_fontsize.X * fragment.text.size(), y + m_fontsize.Y);
|
||||
|
||||
#if USE_FREETYPE
|
||||
if (m_font->getType() == irr::gui::EGFT_CUSTOM) {
|
||||
// Draw colored text if FreeType is enabled
|
||||
irr::gui::CGUITTFont *tmp = dynamic_cast<irr::gui::CGUITTFont *>(m_font);
|
||||
// Draw colored text if possible
|
||||
gui::CGUITTFont *tmp = static_cast<gui::CGUITTFont*>(m_font);
|
||||
tmp->draw(
|
||||
fragment.text,
|
||||
destrect,
|
||||
false,
|
||||
false,
|
||||
&AbsoluteClippingRect);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
// Otherwise use standard text
|
||||
m_font->draw(
|
||||
fragment.text.c_str(),
|
||||
|
|
|
@ -2250,7 +2250,7 @@ void GUIFormSpecMenu::parseBox(parserData* data, const std::string &element)
|
|||
void GUIFormSpecMenu::parseBackgroundColor(parserData* data, const std::string &element)
|
||||
{
|
||||
std::vector<std::string> parts;
|
||||
if (!precheckElement("bgcolor", element, 2, 3, parts))
|
||||
if (!precheckElement("bgcolor", element, 1, 3, parts))
|
||||
return;
|
||||
|
||||
const u32 parameter_count = parts.size();
|
||||
|
@ -2705,7 +2705,7 @@ bool GUIFormSpecMenu::parseStyle(parserData *data, const std::string &element, b
|
|||
void GUIFormSpecMenu::parseSetFocus(const std::string &element)
|
||||
{
|
||||
std::vector<std::string> parts;
|
||||
if (!precheckElement("set_focus", element, 2, 2, parts))
|
||||
if (!precheckElement("set_focus", element, 1, 2, parts))
|
||||
return;
|
||||
|
||||
if (m_is_form_regenerated)
|
||||
|
|
|
@ -17,31 +17,26 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "IGUIEnvironment.h"
|
||||
#include "IGUIElement.h"
|
||||
#include "guiHyperText.h"
|
||||
#include "guiScrollBar.h"
|
||||
#include "IGUIFont.h"
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
using namespace irr::gui;
|
||||
#include "client/fontengine.h"
|
||||
#include <SColor.h>
|
||||
#include "client/tile.h"
|
||||
#include "IVideoDriver.h"
|
||||
#include "client/client.h"
|
||||
#include "client/renderingengine.h"
|
||||
#include "hud.h"
|
||||
#include "guiHyperText.h"
|
||||
#include "util/string.h"
|
||||
#include "irrlicht_changes/CGUITTFont.h"
|
||||
|
||||
bool check_color(const std::string &str)
|
||||
using namespace irr::gui;
|
||||
|
||||
static bool check_color(const std::string &str)
|
||||
{
|
||||
irr::video::SColor color;
|
||||
return parseColorString(str, color, false);
|
||||
}
|
||||
|
||||
bool check_integer(const std::string &str)
|
||||
static bool check_integer(const std::string &str)
|
||||
{
|
||||
if (str.empty())
|
||||
return false;
|
||||
|
@ -616,12 +611,10 @@ TextDrawer::TextDrawer(const wchar_t *text, Client *client,
|
|||
if (e.font) {
|
||||
e.dim.Width = e.font->getDimension(e.text.c_str()).Width;
|
||||
e.dim.Height = e.font->getDimension(L"Yy").Height;
|
||||
#if USE_FREETYPE
|
||||
if (e.font->getType() == irr::gui::EGFT_CUSTOM) {
|
||||
e.baseline = e.dim.Height - 1 -
|
||||
((irr::gui::CGUITTFont *)e.font)->getAscender() / 64;
|
||||
CGUITTFont *tmp = static_cast<CGUITTFont*>(e.font);
|
||||
e.baseline = e.dim.Height - 1 - tmp->getAscender() / 64;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
e.dim = {0, 0};
|
||||
}
|
||||
|
|
|
@ -19,16 +19,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "config.h" // for USE_FREETYPE
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include "irrlichttypes_extrabloated.h"
|
||||
|
||||
using namespace irr;
|
||||
|
||||
class ISimpleTextureSource;
|
||||
class Client;
|
||||
|
||||
#if USE_FREETYPE
|
||||
#include "irrlicht_changes/CGUITTFont.h"
|
||||
#endif
|
||||
class GUIScrollBar;
|
||||
|
||||
class ParsedText
|
||||
{
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
if (BUILD_CLIENT)
|
||||
set(client_irrlicht_changes_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/static_text.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CGUITTFont.cpp
|
||||
)
|
||||
|
||||
if (USE_FREETYPE)
|
||||
set(client_irrlicht_changes_SRCS ${client_irrlicht_changes_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CGUITTFont.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
# CMake require us to set a local scope and then parent scope
|
||||
# Else the last set win in parent scope
|
||||
set(client_irrlicht_changes_SRCS ${client_irrlicht_changes_SRCS} PARENT_SCOPE)
|
||||
|
|
|
@ -12,17 +12,12 @@
|
|||
#include <rect.h>
|
||||
#include <SColor.h>
|
||||
|
||||
#if USE_FREETYPE
|
||||
#include "CGUITTFont.h"
|
||||
#endif
|
||||
|
||||
#include "CGUITTFont.h"
|
||||
#include "util/string.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
#if USE_FREETYPE
|
||||
|
||||
namespace gui
|
||||
{
|
||||
//! constructor
|
||||
|
@ -108,14 +103,12 @@ void StaticText::draw()
|
|||
font->getDimension(str.c_str()).Width;
|
||||
}
|
||||
|
||||
#if USE_FREETYPE
|
||||
if (font->getType() == irr::gui::EGFT_CUSTOM) {
|
||||
irr::gui::CGUITTFont *tmp = static_cast<irr::gui::CGUITTFont*>(font);
|
||||
CGUITTFont *tmp = static_cast<CGUITTFont*>(font);
|
||||
tmp->draw(str,
|
||||
r, HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER,
|
||||
(RestrainTextInside ? &AbsoluteClippingRect : NULL));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
// Draw non-colored text
|
||||
font->draw(str.c_str(),
|
||||
|
@ -590,8 +583,6 @@ s32 StaticText::getTextWidth() const
|
|||
|
||||
} // end namespace gui
|
||||
|
||||
#endif // USE_FREETYPE
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "config.h"
|
||||
#include <IGUIEnvironment.h>
|
||||
|
||||
#if USE_FREETYPE
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -230,41 +229,6 @@ inline void setStaticText(irr::gui::IGUIStaticText *static_text, const EnrichedS
|
|||
}
|
||||
}
|
||||
|
||||
#else // USE_FREETYPE
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace gui
|
||||
{
|
||||
|
||||
class StaticText
|
||||
{
|
||||
public:
|
||||
static irr::gui::IGUIStaticText *add(
|
||||
irr::gui::IGUIEnvironment *guienv,
|
||||
const EnrichedString &text,
|
||||
const core::rect< s32 > &rectangle,
|
||||
bool border = false,
|
||||
bool wordWrap = true,
|
||||
irr::gui::IGUIElement *parent = NULL,
|
||||
s32 id = -1,
|
||||
bool fillBackground = false)
|
||||
{
|
||||
return guienv->addStaticText(text.c_str(), rectangle, border, wordWrap, parent, id, fillBackground);
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace gui
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
inline void setStaticText(irr::gui::IGUIStaticText *static_text, const EnrichedString &text)
|
||||
{
|
||||
static_text->setText(text.c_str());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
inline void setStaticText(irr::gui::IGUIStaticText *static_text, const wchar_t *text)
|
||||
{
|
||||
setStaticText(static_text, EnrichedString(text, static_text->getOverrideColor()));
|
||||
|
|
|
@ -52,14 +52,7 @@ MapSettingsManager::~MapSettingsManager()
|
|||
bool MapSettingsManager::getMapSetting(
|
||||
const std::string &name, std::string *value_out)
|
||||
{
|
||||
// Try getting it normally first
|
||||
if (m_map_settings->getNoEx(name, *value_out))
|
||||
return true;
|
||||
|
||||
// If not we may have to resolve some compatibility kludges
|
||||
if (name == "seed")
|
||||
return Settings::getLayer(SL_GLOBAL)->getNoEx("fixed_map_seed", *value_out);
|
||||
return false;
|
||||
return m_map_settings->getNoEx(name, *value_out);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1018,10 +1018,11 @@ MapgenParams::~MapgenParams()
|
|||
|
||||
void MapgenParams::readParams(const Settings *settings)
|
||||
{
|
||||
std::string seed_str;
|
||||
const char *seed_name = (settings == g_settings) ? "fixed_map_seed" : "seed";
|
||||
// should always be used via MapSettingsManager
|
||||
assert(settings != g_settings);
|
||||
|
||||
if (settings->getNoEx(seed_name, seed_str)) {
|
||||
std::string seed_str;
|
||||
if (settings->getNoEx("seed", seed_str)) {
|
||||
if (!seed_str.empty())
|
||||
seed = read_seed(seed_str.c_str());
|
||||
else
|
||||
|
|
|
@ -482,7 +482,6 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
|
|||
f32 yaw = (f32)f32yaw / 100.0f;
|
||||
u32 keyPressed = 0;
|
||||
|
||||
// default behavior (in case an old client doesn't send these)
|
||||
f32 fov = 0;
|
||||
u8 wanted_range = 0;
|
||||
|
||||
|
@ -508,13 +507,7 @@ void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
|
|||
playersao->setFov(fov);
|
||||
playersao->setWantedRange(wanted_range);
|
||||
|
||||
player->keyPressed = keyPressed;
|
||||
player->control.jump = (keyPressed & (0x1 << 4));
|
||||
player->control.aux1 = (keyPressed & (0x1 << 5));
|
||||
player->control.sneak = (keyPressed & (0x1 << 6));
|
||||
player->control.dig = (keyPressed & (0x1 << 7));
|
||||
player->control.place = (keyPressed & (0x1 << 8));
|
||||
player->control.zoom = (keyPressed & (0x1 << 9));
|
||||
player->control.unpackKeysPressed(keyPressed);
|
||||
|
||||
if (playersao->checkMovementCheat()) {
|
||||
// Call callbacks
|
||||
|
|
|
@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
#include "player.h"
|
||||
|
||||
#include <cmath>
|
||||
#include "threading/mutex_auto_lock.h"
|
||||
#include "util/numeric.h"
|
||||
#include "hud.h"
|
||||
|
@ -159,6 +160,64 @@ void Player::clearHud()
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
|
||||
u32 PlayerControl::getKeysPressed() const
|
||||
{
|
||||
u32 keypress_bits =
|
||||
( (u32)(jump & 1) << 4) |
|
||||
( (u32)(aux1 & 1) << 5) |
|
||||
( (u32)(sneak & 1) << 6) |
|
||||
( (u32)(dig & 1) << 7) |
|
||||
( (u32)(place & 1) << 8) |
|
||||
( (u32)(zoom & 1) << 9)
|
||||
;
|
||||
|
||||
// If any direction keys are pressed pass those through
|
||||
if (direction_keys != 0)
|
||||
{
|
||||
keypress_bits |= direction_keys;
|
||||
}
|
||||
// Otherwise set direction keys based on joystick movement (for mod compatibility)
|
||||
else if (isMoving())
|
||||
{
|
||||
float abs_d;
|
||||
|
||||
// (absolute value indicates forward / backward)
|
||||
abs_d = abs(movement_direction);
|
||||
if (abs_d < 3.0f / 8.0f * M_PI)
|
||||
keypress_bits |= (u32)1; // Forward
|
||||
if (abs_d > 5.0f / 8.0f * M_PI)
|
||||
keypress_bits |= (u32)1 << 1; // Backward
|
||||
|
||||
// rotate entire coordinate system by 90 degree
|
||||
abs_d = movement_direction + M_PI_2;
|
||||
if (abs_d >= M_PI)
|
||||
abs_d -= 2 * M_PI;
|
||||
abs_d = abs(abs_d);
|
||||
// (value now indicates left / right)
|
||||
if (abs_d < 3.0f / 8.0f * M_PI)
|
||||
keypress_bits |= (u32)1 << 2; // Left
|
||||
if (abs_d > 5.0f / 8.0f * M_PI)
|
||||
keypress_bits |= (u32)1 << 3; // Right
|
||||
}
|
||||
|
||||
return keypress_bits;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void PlayerControl::unpackKeysPressed(u32 keypress_bits)
|
||||
{
|
||||
direction_keys = keypress_bits & 0xf;
|
||||
jump = keypress_bits & (1 << 4);
|
||||
aux1 = keypress_bits & (1 << 5);
|
||||
sneak = keypress_bits & (1 << 6);
|
||||
dig = keypress_bits & (1 << 7);
|
||||
place = keypress_bits & (1 << 8);
|
||||
zoom = keypress_bits & (1 << 9);
|
||||
}
|
||||
|
||||
void PlayerSettings::readGlobalSettings()
|
||||
{
|
||||
free_move = g_settings->getBool("free_move");
|
||||
|
|
33
src/player.h
|
@ -49,18 +49,18 @@ struct PlayerControl
|
|||
PlayerControl() = default;
|
||||
|
||||
PlayerControl(
|
||||
bool a_jump,
|
||||
bool a_aux1,
|
||||
bool a_sneak,
|
||||
bool a_up, bool a_down, bool a_left, bool a_right,
|
||||
bool a_jump, bool a_aux1, bool a_sneak,
|
||||
bool a_zoom,
|
||||
bool a_dig,
|
||||
bool a_place,
|
||||
float a_pitch,
|
||||
float a_yaw,
|
||||
float a_movement_speed,
|
||||
float a_movement_direction
|
||||
bool a_dig, bool a_place,
|
||||
float a_pitch, float a_yaw,
|
||||
float a_movement_speed, float a_movement_direction
|
||||
)
|
||||
{
|
||||
// Encode direction keys into a single value so nobody uses it accidentally
|
||||
// as movement_{speed,direction} is supposed to be the source of truth.
|
||||
direction_keys = (a_up&1) | ((a_down&1) << 1) |
|
||||
((a_left&1) << 2) | ((a_right&1) << 3);
|
||||
jump = a_jump;
|
||||
aux1 = a_aux1;
|
||||
sneak = a_sneak;
|
||||
|
@ -72,15 +72,26 @@ struct PlayerControl
|
|||
movement_speed = a_movement_speed;
|
||||
movement_direction = a_movement_direction;
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
// For client use
|
||||
u32 getKeysPressed() const;
|
||||
inline bool isMoving() const { return movement_speed > 0.001f; }
|
||||
#endif
|
||||
|
||||
// For server use
|
||||
void unpackKeysPressed(u32 keypress_bits);
|
||||
|
||||
u8 direction_keys = 0;
|
||||
bool jump = false;
|
||||
bool aux1 = false;
|
||||
bool sneak = false;
|
||||
bool zoom = false;
|
||||
bool dig = false;
|
||||
bool place = false;
|
||||
// Note: These four are NOT available on the server
|
||||
float pitch = 0.0f;
|
||||
float yaw = 0.0f;
|
||||
// Note: These two are NOT available on the server
|
||||
float movement_speed = 0.0f;
|
||||
float movement_direction = 0.0f;
|
||||
};
|
||||
|
@ -189,8 +200,6 @@ public:
|
|||
return m_fov_override_spec;
|
||||
}
|
||||
|
||||
u32 keyPressed = 0;
|
||||
|
||||
HudElement* getHud(u32 id);
|
||||
u32 addHud(HudElement* hud);
|
||||
HudElement* removeHud(u32 id);
|
||||
|
|
|
@ -230,13 +230,15 @@ int LuaLocalPlayer::l_get_control(lua_State *L)
|
|||
set("dig", c.dig);
|
||||
set("place", c.place);
|
||||
// Player movement in polar coordinates and non-binary speed
|
||||
set("movement_speed", c.movement_speed);
|
||||
set("movement_direction", c.movement_direction);
|
||||
lua_pushnumber(L, c.movement_speed);
|
||||
lua_setfield(L, -2, "movement_speed");
|
||||
lua_pushnumber(L, c.movement_direction);
|
||||
lua_setfield(L, -2, "movement_direction");
|
||||
// Provide direction keys to ensure compatibility
|
||||
set("up", player->keyPressed & (1 << 0)); // Up, down, left, and right were removed in favor of
|
||||
set("down", player->keyPressed & (1 << 1)); // analog direction indicators and are therefore not
|
||||
set("left", player->keyPressed & (1 << 2)); // available as booleans anymore. The corresponding values
|
||||
set("right", player->keyPressed & (1 << 3)); // can still be read from the keyPressed bits though.
|
||||
set("up", c.direction_keys & (1 << 0));
|
||||
set("down", c.direction_keys & (1 << 1));
|
||||
set("left", c.direction_keys & (1 << 2));
|
||||
set("right", c.direction_keys & (1 << 3));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -414,25 +414,53 @@ int ModApiMainMenu::l_create_world(lua_State *L)
|
|||
const char *name = luaL_checkstring(L, 1);
|
||||
int gameidx = luaL_checkinteger(L,2) -1;
|
||||
|
||||
StringMap use_settings;
|
||||
luaL_checktype(L, 3, LUA_TTABLE);
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 3) != 0) {
|
||||
// key at index -2 and value at index -1
|
||||
use_settings[luaL_checkstring(L, -2)] = luaL_checkstring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
std::string path = porting::path_user + DIR_DELIM
|
||||
"worlds" + DIR_DELIM
|
||||
+ sanitizeDirName(name, "world_");
|
||||
|
||||
std::vector<SubgameSpec> games = getAvailableGames();
|
||||
|
||||
if ((gameidx >= 0) &&
|
||||
(gameidx < (int) games.size())) {
|
||||
|
||||
// Create world if it doesn't exist
|
||||
try {
|
||||
loadGameConfAndInitWorld(path, name, games[gameidx], true);
|
||||
lua_pushnil(L);
|
||||
} catch (const BaseException &e) {
|
||||
lua_pushstring(L, (std::string("Failed to initialize world: ") + e.what()).c_str());
|
||||
}
|
||||
} else {
|
||||
if (gameidx < 0 || gameidx >= (int) games.size()) {
|
||||
lua_pushstring(L, "Invalid game index");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Set the settings for world creation
|
||||
// this is a bad hack but the best we have right now..
|
||||
StringMap backup;
|
||||
for (auto it : use_settings) {
|
||||
if (g_settings->existsLocal(it.first))
|
||||
backup[it.first] = g_settings->get(it.first);
|
||||
g_settings->set(it.first, it.second);
|
||||
}
|
||||
|
||||
// Create world if it doesn't exist
|
||||
try {
|
||||
loadGameConfAndInitWorld(path, name, games[gameidx], true);
|
||||
lua_pushnil(L);
|
||||
} catch (const BaseException &e) {
|
||||
auto err = std::string("Failed to initialize world: ") + e.what();
|
||||
lua_pushstring(L, err.c_str());
|
||||
}
|
||||
|
||||
// Restore previous settings
|
||||
for (auto it : use_settings) {
|
||||
auto it2 = backup.find(it.first);
|
||||
if (it2 == backup.end())
|
||||
g_settings->remove(it.first); // wasn't set before
|
||||
else
|
||||
g_settings->set(it.first, it2->second); // was set before
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1367,20 +1367,18 @@ int ObjectRef::l_get_player_control(lua_State *L)
|
|||
NO_MAP_LOCK_REQUIRED;
|
||||
ObjectRef *ref = checkobject(L, 1);
|
||||
RemotePlayer *player = getplayer(ref);
|
||||
if (player == nullptr) {
|
||||
lua_pushlstring(L, "", 0);
|
||||
return 1;
|
||||
}
|
||||
if (player == nullptr)
|
||||
return 0;
|
||||
|
||||
const PlayerControl &control = player->getPlayerControl();
|
||||
lua_newtable(L);
|
||||
lua_pushboolean(L, player->keyPressed & (1 << 0));
|
||||
lua_pushboolean(L, control.direction_keys & (1 << 0));
|
||||
lua_setfield(L, -2, "up");
|
||||
lua_pushboolean(L, player->keyPressed & (1 << 1));
|
||||
lua_pushboolean(L, control.direction_keys & (1 << 1));
|
||||
lua_setfield(L, -2, "down");
|
||||
lua_pushboolean(L, player->keyPressed & (1 << 2));
|
||||
lua_pushboolean(L, control.direction_keys & (1 << 2));
|
||||
lua_setfield(L, -2, "left");
|
||||
lua_pushboolean(L, player->keyPressed & (1 << 3));
|
||||
lua_pushboolean(L, control.direction_keys & (1 << 3));
|
||||
lua_setfield(L, -2, "right");
|
||||
lua_pushboolean(L, control.jump);
|
||||
lua_setfield(L, -2, "jump");
|
||||
|
@ -1408,12 +1406,24 @@ int ObjectRef::l_get_player_control_bits(lua_State *L)
|
|||
NO_MAP_LOCK_REQUIRED;
|
||||
ObjectRef *ref = checkobject(L, 1);
|
||||
RemotePlayer *player = getplayer(ref);
|
||||
if (player == nullptr) {
|
||||
lua_pushlstring(L, "", 0);
|
||||
return 1;
|
||||
}
|
||||
if (player == nullptr)
|
||||
return 0;
|
||||
|
||||
lua_pushnumber(L, player->keyPressed);
|
||||
const auto &c = player->getPlayerControl();
|
||||
|
||||
// This is very close to PlayerControl::getKeysPressed() but duplicated
|
||||
// here so the encoding in the API is not inadvertedly changed.
|
||||
u32 keypress_bits =
|
||||
c.direction_keys |
|
||||
( (u32)(c.jump & 1) << 4) |
|
||||
( (u32)(c.aux1 & 1) << 5) |
|
||||
( (u32)(c.sneak & 1) << 6) |
|
||||
( (u32)(c.dig & 1) << 7) |
|
||||
( (u32)(c.place & 1) << 8) |
|
||||
( (u32)(c.zoom & 1) << 9)
|
||||
;
|
||||
|
||||
lua_pushinteger(L, keypress_bits);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -659,9 +659,7 @@ bool Settings::getNoiseParamsFromGroup(const std::string &name,
|
|||
|
||||
bool Settings::exists(const std::string &name) const
|
||||
{
|
||||
MutexAutoLock lock(m_mutex);
|
||||
|
||||
if (m_settings.find(name) != m_settings.end())
|
||||
if (existsLocal(name))
|
||||
return true;
|
||||
if (auto parent = getParent())
|
||||
return parent->exists(name);
|
||||
|
@ -669,6 +667,14 @@ bool Settings::exists(const std::string &name) const
|
|||
}
|
||||
|
||||
|
||||
bool Settings::existsLocal(const std::string &name) const
|
||||
{
|
||||
MutexAutoLock lock(m_mutex);
|
||||
|
||||
return m_settings.find(name) != m_settings.end();
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> Settings::getNames() const
|
||||
{
|
||||
MutexAutoLock lock(m_mutex);
|
||||
|
|
|
@ -172,9 +172,12 @@ public:
|
|||
bool getNoiseParamsFromValue(const std::string &name, NoiseParams &np) const;
|
||||
bool getNoiseParamsFromGroup(const std::string &name, NoiseParams &np) const;
|
||||
|
||||
// return all keys used
|
||||
// return all keys used in this object
|
||||
std::vector<std::string> getNames() const;
|
||||
// check if setting exists anywhere in the hierarchy
|
||||
bool exists(const std::string &name) const;
|
||||
// check if setting exists in this object ("locally")
|
||||
bool existsLocal(const std::string &name) const;
|
||||
|
||||
|
||||
/***************************************
|
||||
|
|
|
@ -37,7 +37,6 @@ const char *g_build_info =
|
|||
#ifndef SERVER
|
||||
"USE_GETTEXT=" STR(USE_GETTEXT) "\n"
|
||||
"USE_SOUND=" STR(USE_SOUND) "\n"
|
||||
"USE_FREETYPE=" STR(USE_FREETYPE) "\n"
|
||||
#endif
|
||||
"STATIC_SHAREDIR=" STR(STATIC_SHAREDIR)
|
||||
#if USE_GETTEXT && defined(STATIC_LOCALEDIR)
|
||||
|
|
|
@ -129,7 +129,6 @@ cmake -S $sourcedir -B . \
|
|||
-DENABLE_SOUND=1 \
|
||||
-DENABLE_CURL=1 \
|
||||
-DENABLE_GETTEXT=1 \
|
||||
-DENABLE_FREETYPE=1 \
|
||||
-DENABLE_LEVELDB=1 \
|
||||
\
|
||||
-DCMAKE_PREFIX_PATH=$libdir/irrlicht \
|
||||
|
|
|
@ -129,7 +129,6 @@ cmake -S $sourcedir -B . \
|
|||
-DENABLE_SOUND=1 \
|
||||
-DENABLE_CURL=1 \
|
||||
-DENABLE_GETTEXT=1 \
|
||||
-DENABLE_FREETYPE=1 \
|
||||
-DENABLE_LEVELDB=1 \
|
||||
\
|
||||
-DCMAKE_PREFIX_PATH=$libdir/irrlicht \
|
||||
|
|